FIX: Recompile theme translations when fallback data changes (#24371)

Previously we would only recompile a theme locale when its own data changes. However, the output also includes fallback data from other locales, so we need to invalidate all locales when fallback locale data is changed. Building a list of dependent locales is tricky, so let's just invalidate them all.
This commit is contained in:
David Taylor
2023-11-14 19:53:27 +00:00
committed by GitHub
parent 69a70f8159
commit eda79186ee
3 changed files with 54 additions and 1 deletions

View File

@ -595,6 +595,57 @@ HTML
expect(fr1.javascript_cache.content).to include("helloworld")
expect(fr1.javascript_cache.content).to include("enval1")
end
it "is recreated when data changes" do
t = Fabricate(:theme)
t.set_field(
target: "translations",
name: "fr",
value: { fr: { mykey: "initial value" } }.deep_stringify_keys.to_yaml,
)
t.save!
field = t.theme_fields.find_by(target_id: Theme.targets[:translations], name: "fr")
expect(field.javascript_cache.content).to include("initial value")
t.set_field(
target: "translations",
name: "fr",
value: { fr: { mykey: "new value" } }.deep_stringify_keys.to_yaml,
)
t.save!
field = t.theme_fields.find_by(target_id: Theme.targets[:translations], name: "fr")
expect(field.javascript_cache.reload.content).to include("new value")
end
it "is recreated when fallback data changes" do
t = Fabricate(:theme)
t.set_field(
target: "translations",
name: "fr",
value: { fr: {} }.deep_stringify_keys.to_yaml,
)
t.set_field(
target: "translations",
name: "en",
value: { en: { myotherkey: "initial value" } }.deep_stringify_keys.to_yaml,
)
t.save!
field = t.theme_fields.find_by(target_id: Theme.targets[:translations], name: "fr")
expect(field.javascript_cache.content).to include("initial value")
t.set_field(
target: "translations",
name: "en",
value: { en: { myotherkey: "new value" } }.deep_stringify_keys.to_yaml,
)
t.save!
field = t.theme_fields.find_by(target_id: Theme.targets[:translations], name: "fr")
expect(field.javascript_cache.reload.content).to include("new value")
end
end
describe "prefix injection" do