1
0
mirror of https://github.com/fspc/BikeShed-1.git synced 2025-02-28 16:53:23 -05:00

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

This commit is contained in:
Jason Denney 2012-12-09 14:26:31 -05:00
parent e41426ea7b
commit 885caefaf7
2 changed files with 29 additions and 2 deletions

View File

@ -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 Normal file
View File

@ -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