mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-26 20:56:48 +00:00
These factories are not used in testing and this way we avoid collisions on the root namespace as it was happening already with OrderFactory
22 lines
507 B
Ruby
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
|