Skip cascading callbacks when touching distributors

This commit is contained in:
Maikel Linke
2019-08-15 10:40:39 +10:00
parent 2137a2addb
commit 48df853ff5
2 changed files with 4 additions and 2 deletions

View File

@@ -464,9 +464,11 @@ class Enterprise < ActiveRecord::Base
self.permalink = Enterprise.find_available_permalink(name)
end
# Touch distributors without them touching their distributors.
# We avoid an infinite loop and don't need to touch the whole distributor tree.
def touch_distributors
Enterprise.distributing_products(supplied_products.select(:id)).
where('enterprises.id != ?', id).
find_each(&:touch)
update_all(updated_at: Time.zone.now)
end
end

View File

@@ -533,7 +533,7 @@ module Spree
)
end
pending "saves without infinite loop" do
it "saves without infinite loop" do
expect(variant1.update_attributes(cost_price: 1)).to be_truthy
end
end