FEATURE: use new site setting for onebox custom user agent. (#28045)

Previously, we couldn't change the user agent name dynamically for onebox requests. In this commit, a new hidden site setting `onebox_user_agent` is created to override the default user agent value specified in the [initializer](c333e9d6e6/config/initializers/100-onebox_options.rb (L15)).

Co-authored-by: Régis Hanol <regis@hanol.fr>
This commit is contained in:
Vinoth Kannan
2024-07-24 04:45:30 +05:30
committed by GitHub
parent 73ce3589ad
commit d681decf01
6 changed files with 66 additions and 26 deletions

View File

@ -211,7 +211,7 @@ RSpec.describe Onebox::Helpers do
context "with custom option" do
around do |example|
previous_options = Onebox.options.to_h
Onebox.options = { user_agent: "EvilTroutBot v0.1" }
Onebox.options = { user_agent: "EvilTroutBot" }
example.run
@ -221,7 +221,7 @@ RSpec.describe Onebox::Helpers do
it "has the custom user agent" do
stub_request(:get, "http://example.com/some-resource").with(
headers: {
"user-agent" => "EvilTroutBot v0.1",
"user-agent" => "EvilTroutBot v#{Discourse::VERSION::STRING}",
},
).to_return(status: 200, body: "test")