mirror of
https://github.com/discourse/discourse.git
synced 2025-06-03 19:39:30 +08:00
FIX: Inline oneboxes should obey the locale. (#30664)
Following on from f369db5ae9a29a23299dff5f14768167230b0b79, we need to apply a similar fix to inline oneboxes, since they use a different code path to retrieve the onebox provider data. This change ensures the Accept-Language header is sent by inline onebox requests, too.
This commit is contained in:
@ -20,19 +20,19 @@ RSpec.describe InlineOneboxer do
|
||||
end
|
||||
|
||||
describe "caching" do
|
||||
fab!(:topic)
|
||||
url = "https://example.com/good-url"
|
||||
|
||||
before { InlineOneboxer.invalidate(topic.url) }
|
||||
|
||||
it "puts an entry in the cache" do
|
||||
before do
|
||||
SiteSetting.enable_inline_onebox_on_all_domains = true
|
||||
url = "https://example.com/good-url"
|
||||
stub_request(:get, url).to_return(
|
||||
status: 200,
|
||||
body: "<html><head><title>a blog</title></head></html>",
|
||||
)
|
||||
|
||||
InlineOneboxer.invalidate(url)
|
||||
end
|
||||
|
||||
it "puts an entry in the cache" do
|
||||
expect(InlineOneboxer.cache_lookup(url)).to be_blank
|
||||
|
||||
result = InlineOneboxer.lookup(url)
|
||||
@ -42,6 +42,34 @@ RSpec.describe InlineOneboxer do
|
||||
expect(cached[:url]).to eq(url)
|
||||
expect(cached[:title]).to eq("a blog")
|
||||
end
|
||||
|
||||
it "separates cache by default_locale" do
|
||||
expect(InlineOneboxer.cache_lookup(url)).to be_blank
|
||||
|
||||
result = InlineOneboxer.lookup(url)
|
||||
expect(result[:title]).to be_present
|
||||
|
||||
cached = InlineOneboxer.cache_lookup(url)
|
||||
expect(cached[:title]).to eq("a blog")
|
||||
|
||||
SiteSetting.default_locale = "fr"
|
||||
|
||||
expect(InlineOneboxer.cache_lookup(url)).to be_blank
|
||||
end
|
||||
|
||||
it "separates cache by onebox_locale, when set" do
|
||||
expect(InlineOneboxer.cache_lookup(url)).to be_blank
|
||||
|
||||
result = InlineOneboxer.lookup(url)
|
||||
expect(result[:title]).to be_present
|
||||
|
||||
cached = InlineOneboxer.cache_lookup(url)
|
||||
expect(cached[:title]).to eq("a blog")
|
||||
|
||||
SiteSetting.onebox_locale = "fr"
|
||||
|
||||
expect(InlineOneboxer.cache_lookup(url)).to be_blank
|
||||
end
|
||||
end
|
||||
|
||||
describe ".lookup" do
|
||||
|
Reference in New Issue
Block a user