mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-23 05:28:53 +00:00
Remove #before_save_hook method and clarify it's intention
This commit is contained in:
committed by
Maikel Linke
parent
f3899ee251
commit
82b8bb74a1
@@ -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
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user