From a56f95d1e3a3f609c1fa9e2610c94c0bc4c45b8d Mon Sep 17 00:00:00 2001 From: filipefurtad0 Date: Tue, 14 Nov 2023 14:36:03 +0000 Subject: [PATCH] Uses more readable DB call Also makes some other minor improvements, like removing the rest case around editing ajustment types, something which we don't really need a test for, as it should not occur in the app --- .../services/order_invoice_comparator_spec.rb | 29 +++++++++---------- 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/spec/services/order_invoice_comparator_spec.rb b/spec/services/order_invoice_comparator_spec.rb index 39ad5a6945..870c5866e3 100644 --- a/spec/services/order_invoice_comparator_spec.rb +++ b/spec/services/order_invoice_comparator_spec.rb @@ -111,17 +111,10 @@ shared_examples "associated attribute changes - adjustments (create/delete)" do end end -shared_examples "associated attribute changes - adjustments (edit)" do |boolean, type| +shared_examples "associated attribute changes - adjustments (edit amount)" do |boolean, type| context "with an existing adjustments" do context "editing the amount" do - before { Spree::Adjustment.first.update!(amount: 123) } - it "returns #{boolean} if a #{type} attribute changes" do - expect(subject).to be boolean - end - end - - context "changing the adjustment type" do - before { Spree::Adjustment.first.update!(adjustable_type: "Spree::Shipment") } + before { order.all_adjustments.first.update!(amount: 123) } it "returns #{boolean} if a #{type} attribute changes" do expect(subject).to be boolean end @@ -129,12 +122,11 @@ shared_examples "associated attribute changes - adjustments (edit)" do |boolean, end end -shared_examples "associated attribute changes - adjustments (update)" do |boolean, type| +shared_examples "associated attribute changes - adjustments (edit label)" do |boolean, type| context "adjustment changes" do - context "with an existing adjustment" do - before { Spree::Adjustment.first.update!(label: "It's a new label") } + context "editing the label" do + before { order.all_adjustments.first.update!(label: "It's a new label") } it "returns #{boolean} if a #{type} attribute changes" do - order.reload expect(subject).to be boolean end end @@ -331,6 +323,8 @@ describe OrderInvoiceComparator do # creating and deleting adjustments is relevant both for generate and update comparator it_behaves_like "associated attribute changes - adjustments (create/delete)", true, "relevant" + it_behaves_like "associated attribute changes - adjustments (edit amount)", true, + "relevant" it_behaves_like "associated attribute changes - bill address", true, "relevant" it_behaves_like "associated attribute changes - ship address", true, "relevant" it_behaves_like "associated attribute changes - line items", true, "relevant" @@ -346,7 +340,7 @@ describe OrderInvoiceComparator do it_behaves_like "no attribute changes" it_behaves_like "attribute changes - special insctructions", false, "non-relevant" it_behaves_like "attribute changes - note", false, "non-relevant" - it_behaves_like "associated attribute changes - adjustments (update)", false, + it_behaves_like "associated attribute changes - adjustments (edit label)", false, "non-relevant" it_behaves_like "attribute changes - payment state", false, "non-relevant" end @@ -369,7 +363,8 @@ describe OrderInvoiceComparator do it_behaves_like "attribute changes - order state: cancelled", true, "relevant" it_behaves_like "attribute changes - special insctructions", true, "relevant" it_behaves_like "attribute changes - note", true, "relevant" - it_behaves_like "associated attribute changes - adjustments (update)", true, "relevant" + it_behaves_like "associated attribute changes - adjustments (edit label)", true, "relevant" + it_behaves_like "attribute changes - payment state", true, "relevant" # creating and deleting adjustments is relevant both for generate and update comparator it_behaves_like "associated attribute changes - adjustments (create/delete)", true, @@ -387,8 +382,10 @@ describe OrderInvoiceComparator do it_behaves_like "associated attribute changes - ship address", false, "non-relevant" it_behaves_like "associated attribute changes - payments", false, "non-relevant" do - before { pending } + before { pending("also related to issue #11350") } end + it_behaves_like "associated attribute changes - adjustments (edit amount)", false, + "non-relevant" end end end