From 6290e7ad1c2c57c86dee42691be6c5d02a28c26c Mon Sep 17 00:00:00 2001 From: Gaetan Craig-Riou Date: Tue, 27 Feb 2024 11:32:50 +1100 Subject: [PATCH] Test the suppliers are touched on destroy --- spec/models/spree/variant_spec.rb | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/spec/models/spree/variant_spec.rb b/spec/models/spree/variant_spec.rb index 5e39aea27e..6a3fac9e13 100644 --- a/spec/models/spree/variant_spec.rb +++ b/spec/models/spree/variant_spec.rb @@ -834,11 +834,18 @@ RSpec.describe Spree::Variant do describe "destruction" do it "destroys exchange variants" do - v = create(:variant) - e = create(:exchange, variants: [v]) + variant = create(:variant) + exchange = create(:exchange, variants: [variant]) - v.destroy - expect(e.reload.variant_ids).to be_empty + variant.destroy + expect(exchange.reload.variant_ids).to be_empty + end + + it "touches the supplier" do + supplier = create(:supplier_enterprise) + variant = create(:variant, supplier:) + + expect { variant.destroy }.to change { supplier.reload.updated_at } end end