mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
Move address factory modification to address_factory file and make it always create a state and country in the address if they dont exist in the DB
This commit is contained in:
@@ -178,11 +178,6 @@ FactoryBot.define do
|
||||
end
|
||||
|
||||
FactoryBot.modify do
|
||||
factory :address do
|
||||
state { Spree::State.find_by name: 'Victoria' }
|
||||
country { Spree::Country.find_by name: 'Australia' || Spree::Country.first }
|
||||
end
|
||||
|
||||
factory :credit_card do
|
||||
cc_type 'visa'
|
||||
end
|
||||
|
||||
@@ -1,5 +1,14 @@
|
||||
FactoryBot.modify do
|
||||
factory :address do
|
||||
state { Spree::State.find_by(name: 'Victoria') || Spree::State.first || create(:state) }
|
||||
country do |address|
|
||||
if address.state
|
||||
address.state.country
|
||||
else
|
||||
Spree::Country.find_by(name: 'Australia') || Spree::Country.first || create(:country)
|
||||
end
|
||||
end
|
||||
|
||||
trait :randomized do
|
||||
firstname { Faker::Name.first_name }
|
||||
lastname { Faker::Name.last_name }
|
||||
|
||||
Reference in New Issue
Block a user