mirror of
https://github.com/discourse/discourse.git
synced 2025-05-30 07:11:34 +08:00
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:
@ -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")
|
||||
|
||||
|
Reference in New Issue
Block a user