From 885caefaf766b921703de5039bd658691e725566 Mon Sep 17 00:00:00 2001 From: Jason Denney Date: Sun, 9 Dec 2012 14:26:31 -0500 Subject: [PATCH] Create factory for seeding db with fake bikes, update seeds.rb --- db/seeds.rb | 12 ++++++++++-- spec/factories/bikes.rb | 19 +++++++++++++++++++ 2 files changed, 29 insertions(+), 2 deletions(-) create mode 100644 spec/factories/bikes.rb diff --git a/db/seeds.rb b/db/seeds.rb index 8a6f041..2cd1d9c 100644 --- a/db/seeds.rb +++ b/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 diff --git a/spec/factories/bikes.rb b/spec/factories/bikes.rb new file mode 100644 index 0000000..9e65460 --- /dev/null +++ b/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