Skip to content

armgit / spree

Public Imported from GitHub
0

Open Source Platform for DTC, B2B Commerce, Marketplaces & Omnichannel. REST APIs, TypeScript SDKs, and production-ready Next.js storefront. Self-host it. Own your data. No vendor lock-in. Zero platform fees.

Fix bug that shows removed item in cart (#11700)

adrianrytaf29e767da76
diff --git a/core/app/services/spree/cart/remove_line_item.rb b/core/app/services/spree/cart/remove_line_item.rb
index ea7a822ed6..046465f6c0 100644
--- a/core/app/services/spree/cart/remove_line_item.rb
+++ b/core/app/services/spree/cart/remove_line_item.rb
@@ -11,6 +11,7 @@ module Spree
line_item: line_item,
options: options)
end
+ order.reload
success(line_item)
end
end
diff --git a/core/spec/services/spree/cart/remove_line_item_spec.rb b/core/spec/services/spree/cart/remove_line_item_spec.rb
index a7bdb8517a..f0eb268e40 100644
--- a/core/spec/services/spree/cart/remove_line_item_spec.rb
+++ b/core/spec/services/spree/cart/remove_line_item_spec.rb
@@ -11,13 +11,28 @@ module Spree
let(:value) { execute.value }
context 'remove line item' do
- it 'with any quantity' do
- expect(order.amount).to eq 200
- expect { execute }.to change { order.line_items.count }.by(-1)
- expect(execute).to be_success
- expect(value).to eq line_item
- order.reload
- expect(order.amount).to eq 0
+ context 'with any quantity' do
+ it 'with any quantity' do
+ expect(order.amount).to eq 200
+ expect { execute }.to change { order.line_items.count }.by(-1)
+ expect(execute).to be_success
+ expect(value).to eq line_item
+ expect(order.amount).to eq 0
+ end
+ end
+
+ context 'with many unique items' do
+ let(:order) { create(:order_with_line_items, line_items_count: 2) }
+ let(:line_item) {order.line_items.first}
+
+ it 'from order with many unique items' do
+ expect(order.amount).to eq 20
+ expect(order.line_items.count).to eq 2
+ expect { execute }.to change { order.line_items.count }.by(-1)
+ expect(execute).to be_success
+ expect(value).to eq line_item
+ expect(order.amount).to eq 10
+ end
end
end