mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-02 21:57:17 +00:00
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:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user