Browse Source

Create factory for seeding db with fake bikes, update seeds.rb

denney-disable-on-select
Jason Denney 12 years ago
parent
commit
885caefaf7
  1. 12
      db/seeds.rb
  2. 19
      spec/factories/bikes.rb

12
db/seeds.rb

@ -19,6 +19,14 @@ if BikeBrand.all.empty? and BikeModel.all.empty?
end
if Rails.env.development?
user = FactoryGirl.build(:user)
FactoryGirl.create(:user) if not User.find_by_email(user.email)
#create default dev user
FactoryGirl.create(:user) if User.all.empty?
#create fake bikes
if Bike.all.empty?
42.times do |n|
FactoryGirl.create(:bike)
end
end
end

19
spec/factories/bikes.rb

@ -0,0 +1,19 @@
# Read about factories at https://github.com/thoughtbot/factory_girl
FactoryGirl.define do
factory :bike do
sequence :serial_number do |n|
"S/N# #{n}"
end
bike_brand_id 1
bike_model_id 1
color "FFFFFF"
bike_style_id 1
seat_tube_height 5
top_tube_length 6
wheel_size 27
value 100
bike_condition_id 1
bike_status_id 1
end
end
Loading…
Cancel
Save