diff --git a/app/models/enterprise.rb b/app/models/enterprise.rb index e696bc3829..e00736b8f2 100644 --- a/app/models/enterprise.rb +++ b/app/models/enterprise.rb @@ -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 diff --git a/spec/models/spree/variant_spec.rb b/spec/models/spree/variant_spec.rb index f9d4006ebf..c59b0795b1 100644 --- a/spec/models/spree/variant_spec.rb +++ b/spec/models/spree/variant_spec.rb @@ -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