diff --git a/app/models/spree/classification_decorator.rb b/app/models/spree/classification_decorator.rb index fec270bc14..20608bad94 100644 --- a/app/models/spree/classification_decorator.rb +++ b/app/models/spree/classification_decorator.rb @@ -1,5 +1,6 @@ Spree::Classification.class_eval do belongs_to :product, class_name: "Spree::Product", touch: true + belongs_to :taxon, class_name: "Spree::Taxon", touch: true before_destroy :dont_destroy_if_primary_taxon diff --git a/spec/models/spree/taxon_spec.rb b/spec/models/spree/taxon_spec.rb index 5a565c5146..b19f979d99 100644 --- a/spec/models/spree/taxon_spec.rb +++ b/spec/models/spree/taxon_spec.rb @@ -28,5 +28,14 @@ module Spree expect(Taxon.distributed_taxons(:current)).to eq(e.id => Set.new([t1.id])) end end + + describe "touches" do + let!(:taxon) { create(:taxon) } + let!(:product) { create(:simple_product) } + + it "is touched when applied to a product" do + expect{ product.taxons << taxon }.to change { taxon.reload.updated_at } + end + end end end