From b6faa43879190e600cc6de9a5f2694d15474ba1d Mon Sep 17 00:00:00 2001 From: Gaetan Craig-Riou Date: Tue, 11 Jun 2024 12:21:02 +1000 Subject: [PATCH] Fix touching distributor callback spec The original spec check if the supplier and distributor where updated after deleting product. In reality, the supplier and the distributor are the same, so no need to test with the supplier --- spec/models/spree/product_spec.rb | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/spec/models/spree/product_spec.rb b/spec/models/spree/product_spec.rb index fbe396b709..0a6e6267cf 100644 --- a/spec/models/spree/product_spec.rb +++ b/spec/models/spree/product_spec.rb @@ -283,19 +283,13 @@ module Spree let(:product) { create(:simple_product) } describe "touching affected enterprises when the product is deleted" do - let(:supplier) { create(:supplier_enterprise) } + let(:product) { create(:simple_product, supplier_id: distributor.id) } let(:distributor) { create(:distributor_enterprise) } + let(:supplier) { create(:supplier_enterprise) } let!(:oc) { create(:simple_order_cycle, distributors: [distributor], variants: [product.variants.first]) } - before do - create(:variant, product:, supplier:) - end - - it "touches the supplier" do - expect { product.destroy }.to change { supplier.reload.updated_at } - end it "touches all distributors" do expect { product.destroy }.to change { distributor.reload.updated_at } @@ -321,7 +315,7 @@ module Spree product.variants = [] product.save! - expect { product.update(primary_taxon_id: new_taxon.id) }.to_not raise_error + expect { product.update(primary_taxon_id: new_taxon.id) }.not_to raise_error end end end @@ -339,7 +333,7 @@ module Spree it "doesn't blow up" do product.variants.first.update_attribute(:supplier_id, nil) - expect { product.touch }.to_not raise_error + expect { product.touch }.not_to raise_error end end end