Enable products cache by default only in staging and production

We keep tests running by default without cache, keeping it as it was before 10a79d5a65

Additionally, cached_products_renderer no longer depends on Rails.env, so here we remove that dependency from it's spec.
This commit is contained in:
luisramos0
2019-03-17 10:19:50 +00:00
parent 60ee17204b
commit 22a051e720
2 changed files with 3 additions and 14 deletions

View File

@@ -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

View File

@@ -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