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