Skip to content

Commit

Permalink
Merge pull request #12954 from rioug/fix-shipment-not-updated
Browse files Browse the repository at this point in the history
Ensure shipment gets updated when an order is updated
  • Loading branch information
filipefurtad0 authored Dec 26, 2024
2 parents b8aa970 + cedf040 commit 5fdd0e5
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions app/models/spree/order_contents.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ def update_or_create(variant, attributes)
line_item.price = variant.price
order.line_items << line_item
end
update_shipment

order.reload
line_item
Expand Down
12 changes: 12 additions & 0 deletions spec/models/spree/order_contents_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,12 @@
expect(line_item.max_quantity).to eq 3
expect(line_item.price).to eq variant.price
end

it "ensures shipments are updated" do
expect(order).to receive(:ensure_updated_shipments)

subject.update_or_create(variant, { quantity: 2, max_quantity: 3 })
end
end

describe "updating" do
Expand All @@ -186,6 +192,12 @@
expect(line_item.reload.quantity).to eq 3
expect(line_item.max_quantity).to eq 4
end

it "ensures shipments are updated" do
expect(order).to receive(:ensure_updated_shipments)

subject.update_or_create(variant, { quantity: 3, max_quantity: 4 })
end
end
end
end

0 comments on commit 5fdd0e5

Please sign in to comment.