From 310df39e2792eebede4e1d00fc204557b365b516 Mon Sep 17 00:00:00 2001 From: Ben Halpern Date: Wed, 9 Sep 2020 16:58:04 -0400 Subject: [PATCH] Include locale in fragment cache key (#10199) * Include locale in fragment cache key * Adjust specs --- app/helpers/application_helper.rb | 2 +- spec/helpers/application_helper_spec.rb | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 842511056..edd5b39a1 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -184,7 +184,7 @@ module ApplicationHelper release_footprint = ApplicationConfig["RELEASE_FOOTPRINT"] return path if release_footprint.blank? - "#{path}-#{release_footprint}" + "#{path}-#{params[:locale]}-#{release_footprint}" end def copyright_notice diff --git a/spec/helpers/application_helper_spec.rb b/spec/helpers/application_helper_spec.rb index 8f46c3675..caddc6399 100644 --- a/spec/helpers/application_helper_spec.rb +++ b/spec/helpers/application_helper_spec.rb @@ -43,7 +43,13 @@ RSpec.describe ApplicationHelper, type: :helper do it "appends the RELEASE_FOOTPRINT if it is set" do allow(ApplicationConfig).to receive(:[]).with("RELEASE_FOOTPRINT").and_return("abc123") - expect(helper.release_adjusted_cache_key("cache-me")).to eq("cache-me-abc123") + expect(helper.release_adjusted_cache_key("cache-me")).to eq("cache-me--abc123") + end + + it "includes locale param if it is set" do + allow(ApplicationConfig).to receive(:[]).with("RELEASE_FOOTPRINT").and_return("abc123") + params[:locale] = "fr-ca" + expect(helper.release_adjusted_cache_key("cache-me")).to eq("cache-me-fr-ca-abc123") end end