From b780823970e2d4b53c8525d8f8ad78adea4c9bf4 Mon Sep 17 00:00:00 2001 From: luisramos0 Date: Wed, 27 Mar 2019 13:47:04 +0000 Subject: [PATCH] Fix specs to adapt to the fact that for the order workflow to get to delivery, the shipping method must be linked to the order distributor otherwise it's ignored when creating the order shipment --- spec/factories.rb | 1 + spec/models/proxy_order_spec.rb | 4 +++- spec/services/order_factory_spec.rb | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/spec/factories.rb b/spec/factories.rb index 5c178d0a78..5f2d2c809f 100644 --- a/spec/factories.rb +++ b/spec/factories.rb @@ -443,6 +443,7 @@ FactoryBot.define do shipment = order.reload.shipments.first if shipment.nil? shipping_method = create(:shipping_method_with, :shipping_fee, shipping_fee: shipping_fee) + shipping_method.distributors << order.distributor if order.distributor shipment = create(:shipment_with, :shipping_method, shipping_method: shipping_method, order: order) end shipment diff --git a/spec/models/proxy_order_spec.rb b/spec/models/proxy_order_spec.rb index d7c0a1ba8d..2e15c39cc6 100644 --- a/spec/models/proxy_order_spec.rb +++ b/spec/models/proxy_order_spec.rb @@ -78,7 +78,9 @@ describe ProxyOrder, type: :model do describe "resume" do let!(:payment_method) { create(:payment_method) } let!(:shipment) { create(:shipment) } - let(:order) { create(:order_with_totals, ship_address: create(:address), shipments: [shipment]) } + let(:order) { create(:order_with_totals, ship_address: create(:address), + shipments: [shipment], + distributor: shipment.shipping_method.distributors.first) } let(:proxy_order) { create(:proxy_order, order: order, canceled_at: Time.zone.now) } let(:order_cycle) { proxy_order.order_cycle } diff --git a/spec/services/order_factory_spec.rb b/spec/services/order_factory_spec.rb index a1b47c0282..7c9c0bd7d5 100644 --- a/spec/services/order_factory_spec.rb +++ b/spec/services/order_factory_spec.rb @@ -8,7 +8,7 @@ describe OrderFactory do let(:shop) { create(:distributor_enterprise) } let(:order_cycle) { create(:simple_order_cycle) } let!(:other_shipping_method_a) { create(:shipping_method) } - let!(:shipping_method) { create(:shipping_method) } + let!(:shipping_method) { create(:shipping_method, distributors: [shop]) } let!(:other_shipping_method_b) { create(:shipping_method) } let(:payment_method) { create(:payment_method) } let(:ship_address) { create(:address) }