diff --git a/core/app/models/spree/product.rb b/core/app/models/spree/product.rb index a5123dc70bc..1b9cf3e6b92 100644 --- a/core/app/models/spree/product.rb +++ b/core/app/models/spree/product.rb @@ -25,7 +25,7 @@ class Product < Spree::Base variants_including_master.discard_all self.product_option_types = [] self.product_properties = [] - self.classifications = [] + self.classifications.destroy_all self.product_promotion_rules = [] end diff --git a/core/spec/models/spree/classification_spec.rb b/core/spec/models/spree/classification_spec.rb index 9af2e00cb93..5013653766a 100644 --- a/core/spec/models/spree/classification_spec.rb +++ b/core/spec/models/spree/classification_spec.rb @@ -44,6 +44,18 @@ def positions_to_be_valid(taxon) end end + context "Discard'ing a product" do + before :each do + element = taxon_with_5_products.products[1] + expect(element.classifications.first.position).to eq(2) + element.discard + end + + it "resets positions" do + expect positions_to_be_valid(taxon_with_5_products) + end + end + context "replacing taxon's products" do before :each do products = taxon_with_5_products.products.to_a