FEATURE: Add a onebox_locale site setting. (#30655)

Following on from f369db5ae9a29a23299dff5f14768167230b0b79, this change adds the ability to choose a custom locale to send to onebox providers.

If this setting is left blank, it will fall back to using default_locale.
This commit is contained in:
Gary Pendergast
2025-01-09 14:11:37 +11:00
committed by GitHub
parent 590b3e11fb
commit f53c734ba6
7 changed files with 66 additions and 17 deletions

View File

@ -957,11 +957,18 @@ RSpec.describe Oneboxer do
end
it "separates cache by default_locale" do
preview = Oneboxer.preview(url, invalidate_oneboxes: true)
Oneboxer.preview(url, invalidate_oneboxes: true)
expect(Oneboxer.cached_response_body_exists?(url)).to eq(true)
SiteSetting.default_locale = "fr"
expect(Oneboxer.cached_response_body_exists?(url)).to eq(false)
end
it "separates cache by onebox_locale, when set" do
Oneboxer.preview(url, invalidate_oneboxes: true)
expect(Oneboxer.cached_response_body_exists?(url)).to eq(true)
SiteSetting.onebox_locale = "fr"
expect(Oneboxer.cached_response_body_exists?(url)).to eq(false)
end
end
describe "register_local_handler" do