mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-27 01:43:22 +00:00
Touch taxon when a taxon is applied to a product
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user