From 90589ae86844714ad81d8d1b04153eee7865bb9e Mon Sep 17 00:00:00 2001 From: Maikel Linke Date: Wed, 23 Oct 2024 16:35:59 +1100 Subject: [PATCH] Spec restock after order cancellation --- spec/models/spree/order_spec.rb | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/spec/models/spree/order_spec.rb b/spec/models/spree/order_spec.rb index 8845335a42..acd2881a36 100644 --- a/spec/models/spree/order_spec.rb +++ b/spec/models/spree/order_spec.rb @@ -400,6 +400,27 @@ RSpec.describe Spree::Order do end end end + + it "restocks items without reload" do + pending "Cancelling a newly created order updates shipments without callbacks" + # But in production, orders are always created in one request and + # cancelled in another request. This is only an issue in specs. + + expect { order.cancel }.to change { + order.variants.first.on_hand + }.by(1) + end + + it "restocks items" do + # If we don't reload the order, it keeps thinking that its shipping + # address changed and triggers a shipment update without shipment + # callbacks. This can be removed if the above spec passes. + order.reload + + expect { order.cancel }.to change { + order.variants.first.on_hand + }.by(1) + end end describe "#resume" do