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

This commit is contained in:
luisramos0
2019-03-27 13:47:04 +00:00
parent ae66e864a5
commit b780823970
3 changed files with 5 additions and 2 deletions

View File

@@ -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

View File

@@ -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 }

View File

@@ -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) }