diff --git a/app/models/spree/order.rb b/app/models/spree/order.rb index 6ba226f222..cbcef134a7 100644 --- a/app/models/spree/order.rb +++ b/app/models/spree/order.rb @@ -372,7 +372,7 @@ module Spree end updater.update_shipment_state - updater.before_save_hook + updater.shipping_address_from_distributor save deliver_order_confirmation_email diff --git a/engines/order_management/app/services/order_management/order/updater.rb b/engines/order_management/app/services/order_management/order/updater.rb index fc727d7e35..00815e322c 100644 --- a/engines/order_management/app/services/order_management/order/updater.rb +++ b/engines/order_management/app/services/order_management/order/updater.rb @@ -140,10 +140,6 @@ module OrderManagement order.all_adjustments.reload.each(&:update_adjustment!) end - def before_save_hook - shipping_address_from_distributor - end - # Sets the distributor's address as shipping address of the order for those # shipments using a shipping method that doesn't require address, such us # a pickup. diff --git a/engines/order_management/spec/services/order_management/order/updater_spec.rb b/engines/order_management/spec/services/order_management/order/updater_spec.rb index 6c5ecbdbf3..fd549e415a 100644 --- a/engines/order_management/spec/services/order_management/order/updater_spec.rb +++ b/engines/order_management/spec/services/order_management/order/updater_spec.rb @@ -279,7 +279,7 @@ module OrderManagement end end - context '#before_save_hook' do + context '#shipping_address_from_distributor' do let(:distributor) { build(:distributor_enterprise) } let(:shipment) { create(:shipment_with, :shipping_method, shipping_method: shipping_method) @@ -296,7 +296,7 @@ module OrderManagement before { distributor.address = address } it "populates the shipping address from distributor" do - updater.before_save_hook + updater.shipping_address_from_distributor expect(order.ship_address.address1).to eq(distributor.address.address1) end end @@ -307,7 +307,7 @@ module OrderManagement before { order.ship_address = address } it "does not populate the shipping address from distributor" do - updater.before_save_hook + updater.shipping_address_from_distributor expect(order.ship_address.firstname).to eq("will") end end diff --git a/spec/models/spree/order_spec.rb b/spec/models/spree/order_spec.rb index e73de877a0..3f667298eb 100644 --- a/spec/models/spree/order_spec.rb +++ b/spec/models/spree/order_spec.rb @@ -207,8 +207,8 @@ describe Spree::Order do order.finalize! end - it 'calls updater#before_save' do - expect(order.updater).to receive(:before_save_hook) + it 'calls updater#shipping_address_from_distributor' do + expect(order.updater).to receive(:shipping_address_from_distributor) order.finalize! end end