From 745758b7deecf540a53ce397f0ed8d4b979004aa Mon Sep 17 00:00:00 2001 From: George Thoppil <45666083+georgethoppil@users.noreply.github.com> Date: Mon, 24 Jan 2022 09:06:09 -0500 Subject: [PATCH] Update spec/models/spree/order_spec.rb Co-authored-by: Matt-Yorkley <9029026+Matt-Yorkley@users.noreply.github.com> --- spec/models/spree/order_spec.rb | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/spec/models/spree/order_spec.rb b/spec/models/spree/order_spec.rb index e09e663396..24166b4f50 100644 --- a/spec/models/spree/order_spec.rb +++ b/spec/models/spree/order_spec.rb @@ -284,12 +284,15 @@ describe Spree::Order do expect(order.can_cancel?).to be_truthy end - it "should cancel order if product is soft deleted" do - o = FactoryBot.create(:completed_order_with_totals) - o.line_items.first.variant.product.tap(&:destroy) - o.cancel! - expect(Spree::Order.by_state(:canceled)).to include o - end + context "with a soft-deleted product" do + let(:order) { create(:completed_order_with_totals) } + + it "should cancel the order without error" do + order.line_items.first.variant.product.tap(&:destroy) + order.cancel! + expect(Spree::Order.by_state(:canceled)).to include order + end + end end context "insufficient_stock_lines" do