FIX: report cached controller and action to loggers

Previously we would treat all cached hits in anon cache as "other"

This hinders analysis of cache performance and makes logging inaccurate
This commit is contained in:
Sam Saffron
2019-09-03 10:51:49 +10:00
parent 441e573439
commit b9954b53bb
2 changed files with 27 additions and 4 deletions

View File

@ -277,12 +277,24 @@ describe Middleware::RequestTracker do
tracker = Middleware::RequestTracker.new(cache)
uri = "/path?#{SecureRandom.hex}"
tracker.call(env("REQUEST_URI" => uri, "ANON_CACHE_DURATION" => 60))
request_params = {
"a" => "b",
"action" => "bob",
"controller" => "jane"
}
tracker.call(env("REQUEST_URI" => uri, "ANON_CACHE_DURATION" => 60, "action_dispatch.request.parameters" => request_params))
expect(@data[:cache]).to eq("store")
tracker.call(env("REQUEST_URI" => uri, "ANON_CACHE_DURATION" => 60))
expect(@data[:cache]).to eq("true")
# not whitelisted
request_params.delete("a")
expect(@env["action_dispatch.request.parameters"]).to eq(request_params)
end
it "can correctly log detailed data" do