Skip to content

Instantly share code, notes, and snippets.

@dangalipo
Created October 7, 2011 03:38
Show Gist options
  • Select an option

  • Save dangalipo/1269384 to your computer and use it in GitHub Desktop.

Select an option

Save dangalipo/1269384 to your computer and use it in GitHub Desktop.
Factories
Factory.define :van_driver do |f|
f.after_build do |ff|
ff.van = Factory.build(:van)
end
f.after_create do |ff|
ff.van.save!
end
f.association :user
end
Factory.define :van do |f|
f.LicencePlate { "abcd123"}
f.OwnerID { Factory(:van_driver).ID}
f.VIN { "abcde1234"}
end
Factory.define :user do |f|
f.api_token { ActiveSupport::SecureRandom.hex(40) }
f.first_name { Faker::Name.first_name }
f.last_name { Faker::Name.last_name }
f.email { Faker::Internet.email }
f.uuid { ActiveSupport::SecureRandom.hex(40) }
f.password { 'password' }
f.ShippingSuburbID { Factory(:suburb).ID }
f.SMSToManager { rand(10) }
f.AvailablePublicHolidays { 1 }
f.LastLoggedIn { Date.today }
f.franchise_name { Faker::Name.first_name }
f.franchise_phone_number { Faker::PhoneNumber.phone_number }
f.franchise_abn { '%011d' % rand(1e10) }
f.franchise_terms_of_payment { Faker::Lorem.paragraphs(2).join }
f.franchise_bank { Faker::Company.name }
f.franchise_bsb { '%06d' % rand(1e6) }
f.franchise_account_number { '%010d' % rand(1e10) }
f.franchise_ref { '%05d' % rand(1e5) }
f.after_build do |ff|
ff.van = Factory.build(:van)
end
f.after_create do |ff|
ff.van.save!
end
f.association :potential
f.association :suburb
f.association :invoice_logo
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment