Remove #order_update! from line item after_save callback

This commit is contained in:
Matt-Yorkley
2021-05-11 02:52:04 +01:00
parent a124141537
commit 03fc63ad14
5 changed files with 10 additions and 5 deletions

View File

@@ -230,7 +230,6 @@ module Spree
# update the order totals, etc.
order.create_tax_charge!
order.update_order!
end
def update_inventory_before_destroy

View File

@@ -76,6 +76,7 @@ module Spree
end
def update_order
order.update_order!
order.reload
end
end

View File

@@ -212,7 +212,7 @@ describe Admin::BulkLineItemsController, type: :controller do
expect(line_item1.order).to receive(:reload).with(lock: true)
expect(line_item1.order).to receive(:update_line_item_fees!)
expect(line_item1.order).to receive(:update_order_fees!)
expect(line_item1.order).to receive(:update_order!).twice
expect(line_item1.order).to receive(:update_order!)
spree_put :update, params
end

View File

@@ -11,7 +11,6 @@ module Spree
it 'should update inventory, totals, and tax' do
# Regression check for Spree #1481
expect(line_item.order).to receive(:create_tax_charge!)
expect(line_item.order).to receive(:update_order!)
line_item.quantity = 2
line_item.save
end

View File

@@ -443,7 +443,10 @@ describe OrderSyncer do
before { variant.update_attribute(:on_hand, 3) }
context "when the changed line_item quantity matches the new quantity on the subscription line item" do
before { changed_line_item.update(quantity: 3) }
before do
changed_line_item.update(quantity: 3)
order.update_order!
end
it "does not change the quantity, and doesn't add the order to order_update_issues" do
expect(order.reload.total.to_f).to eq 99.95
@@ -456,7 +459,10 @@ describe OrderSyncer do
end
context "when the changed line_item quantity doesn't match the new quantity on the subscription line item" do
before { changed_line_item.update(quantity: 2) }
before do
changed_line_item.update(quantity: 2)
order.update_order!
end
it "does not change the quantity, and adds the order to order_update_issues" do
expect(order.reload.total.to_f).to eq 79.96