Files
openfoodnetwork/lib/tasks/sample_data/customer_factory.rb
Luis Ramos 5289a5b381 Add namespace to all sample data factories
These factories are not used in testing and this way we avoid collisions on the root namespace as it was happening already with OrderFactory
2020-11-10 22:03:36 +00:00

22 lines
507 B
Ruby

require "tasks/sample_data/logging"
module SampleData
class CustomerFactory
include Logging
def create_samples(users)
log "Creating customers"
jane = users["Jane Customer"]
maryse_shop = Enterprise.find_by(name: "Maryse's Private Shop")
return if Customer.where(user_id: jane, enterprise_id: maryse_shop).exists?
log "- #{jane.email}"
Customer.create!(
email: jane.email,
user: jane,
enterprise: maryse_shop
)
end
end
end