From 145b4385a40ff0b481f596c25819f1af457b314f Mon Sep 17 00:00:00 2001 From: luisramos0 Date: Tue, 11 Sep 2018 22:20:25 +0100 Subject: [PATCH] Fixed db:load_sample_data shipping_method build --- lib/tasks/dev.rake | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/lib/tasks/dev.rake b/lib/tasks/dev.rake index 6fa9af6f3e7..2329c3498a0 100644 --- a/lib/tasks/dev.rake +++ b/lib/tasks/dev.rake @@ -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