mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-09 03:20:21 +00:00
Add "v1" to locale cache key
This is to invalidate existing locale cache key, so it will pick up image path changes in cached fragment with locale
This commit is contained in:
@@ -72,7 +72,8 @@ module ApplicationHelper
|
||||
end
|
||||
end
|
||||
|
||||
# Update "v1" to invalidate existing cache key
|
||||
def cache_key_with_locale(key, locale)
|
||||
Array.wrap(key) + [locale.to_s, I18nDigests.for_locale(locale)]
|
||||
Array.wrap(key) + ["v1", locale.to_s, I18nDigests.for_locale(locale)]
|
||||
end
|
||||
end
|
||||
|
||||
@@ -89,13 +89,13 @@ RSpec.describe ApplicationHelper do
|
||||
it "appends locale and digest to a single key" do
|
||||
expect(
|
||||
helper.cache_key_with_locale("single-key", "en")
|
||||
).to eq(["single-key", "en", en_digest])
|
||||
).to eq(["single-key", "v1", "en", en_digest])
|
||||
end
|
||||
|
||||
it "appends locale and digest to multiple keys" do
|
||||
expect(
|
||||
helper.cache_key_with_locale(["array", "of", "keys"], "es")
|
||||
).to eq(["array", "of", "keys", "es", es_digest])
|
||||
).to eq(["array", "of", "keys", "v1", "es", es_digest])
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user