DEV: Include controller namespace in X-Discourse-Route (#29783)

* DEV: Include controller namespace in X-Discourse-Route

* use same separator
This commit is contained in:
Osama Sayegh 2024-11-29 09:11:17 +03:00 committed by GitHub
parent fd2a82f41a
commit 1497b298d2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 17 additions and 1 deletions

View File

@ -365,7 +365,7 @@ class ApplicationController < ActionController::Base
Logster.add_to_env(request.env, "username", current_user.username)
response.headers["X-Discourse-Username"] = current_user.username
end
response.headers["X-Discourse-Route"] = "#{controller_name}/#{action_name}"
response.headers["X-Discourse-Route"] = "#{controller_path}/#{action_name}"
end
def set_mp_snapshot_fields

View File

@ -1498,4 +1498,20 @@ RSpec.describe ApplicationController do
end
end
end
describe "#set_current_user_for_logs" do
fab!(:admin)
it "sets the X-Discourse-Route header to the controller name and action including namespace" do
sign_in(admin)
get "/admin/users/#{admin.id}.json"
expect(response.status).to eq(200)
expect(response.headers["X-Discourse-Route"]).to eq("admin/users/show")
get "/u/#{admin.username}.json"
expect(response.status).to eq(200)
expect(response.headers["X-Discourse-Route"]).to eq("users/show")
end
end
end