diff --git a/app/models/spree/app_configuration_decorator.rb b/app/models/spree/app_configuration_decorator.rb index 6259c84902..2df7c02ea7 100644 --- a/app/models/spree/app_configuration_decorator.rb +++ b/app/models/spree/app_configuration_decorator.rb @@ -39,5 +39,5 @@ Spree::AppConfiguration.class_eval do preference :enable_localized_number?, :boolean, default: false # Enable cache - preference :enable_products_cache?, :boolean, default: !Rails.env.development? + preference :enable_products_cache?, :boolean, default: (Rails.env.production? || Rails.env.staging?) end diff --git a/spec/lib/open_food_network/cached_products_renderer_spec.rb b/spec/lib/open_food_network/cached_products_renderer_spec.rb index 6bff04dad2..61de635f20 100644 --- a/spec/lib/open_food_network/cached_products_renderer_spec.rb +++ b/spec/lib/open_food_network/cached_products_renderer_spec.rb @@ -27,7 +27,6 @@ module OpenFoodNetwork context "products cache toggle" do before do - allow(Rails.env).to receive(:production?) { true } Rails.cache.write "products-json-#{distributor.id}-#{order_cycle.id}", 'products' end @@ -52,19 +51,9 @@ module OpenFoodNetwork end end - context "when in testing / development" do + context "products cache enabled" do before do - allow(Rails.env).to receive(:production?) { false } - end - - it "returns uncached products JSON" do - expect(cached_products_renderer.products_json).to eq 'uncached products' - end - end - - context "when in production / staging" do - before do - allow(Rails.env).to receive(:production?) { true } + Spree::Config[:enable_products_cache?] = true end describe "when the distribution is not set" do