From 62c6530ca93319fd88d36e01f463762bbd246748 Mon Sep 17 00:00:00 2001 From: Rohan Mitchell Date: Thu, 4 Feb 2016 12:15:59 +1100 Subject: [PATCH] Do not refresh products cache when price destroyed - variant destruction is main (only?) trigger, it causes refresh --- app/models/spree/price_decorator.rb | 1 - spec/models/spree/price_spec.rb | 6 ++---- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/app/models/spree/price_decorator.rb b/app/models/spree/price_decorator.rb index 0dd3a5a0c6..f50a86066b 100644 --- a/app/models/spree/price_decorator.rb +++ b/app/models/spree/price_decorator.rb @@ -1,7 +1,6 @@ module Spree Price.class_eval do after_save :refresh_products_cache - after_destroy :refresh_products_cache private diff --git a/spec/models/spree/price_spec.rb b/spec/models/spree/price_spec.rb index 378925f052..5d48afd95b 100644 --- a/spec/models/spree/price_spec.rb +++ b/spec/models/spree/price_spec.rb @@ -12,10 +12,8 @@ module Spree price.save end - it "refreshes the products cache on destroy" do - expect(OpenFoodNetwork::ProductsCache).to receive(:variant_changed).with(variant) - price.destroy - end + # Do not refresh on price destruction - this (only?) happens when variant is destroyed, + # and in that case the variant will take responsibility for refreshing the cache it "does not refresh the cache when variant is not set" do # Creates a price without the back link to variant