Fixed db:load_sample_data shipping_method build

This commit is contained in:
luisramos0
2018-09-11 22:20:25 +01:00
parent e58f7269c3
commit 145b4385a4

View File

@@ -184,13 +184,12 @@ namespace :openfoodnetwork do
enterprise2 = Enterprise.find_by_name('Enterprise 2')
enterprise2.sells = 'any'
enterprise2.shipping_methods.build(
name: 'Pickup',
zone_id: 3,
require_ship_address: true,
calculator_type: 'OpenFoodNetwork::Calculator::Weight',
distributor_ids: [enterprise2.id]
)
enterprise2.shipping_methods << FactoryBot.create(:shipping_method,
name: 'Pickup',
zone: zone,
require_ship_address: true,
calculator_type: 'OpenFoodNetwork::Calculator::Weight',
distributors: [enterprise2])
enterprise2.payment_methods << Spree::PaymentMethod.last
enterprise2.save!
@@ -200,7 +199,9 @@ namespace :openfoodnetwork do
CreateOrderCycle.new(enterprise2, variants).call
EnterpriseRole.create!(user: Spree::User.first, enterprise: enterprise2)
unless EnterpriseRole.where( user_id: Spree::User.first, enterprise_id: enterprise2 ).any?
EnterpriseRole.create!(user: Spree::User.first, enterprise: enterprise2)
end
end
end
end