Skip to content
This repository has been archived by the owner on Dec 8, 2023. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge pull request #78 from heroku/do-not-mutate-env-request-method
Change downcase! to downcase to prevent mutation
  • Loading branch information
Maia Engeli committed Aug 7, 2018
2 parents 042daa2 + ecb9025 commit 4c5cd0c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/librato/rack.rb
Expand Up @@ -50,7 +50,7 @@ class Rack
EOS

RECORD_RACK_METHOD_BODY = <<-'EOS'
method_tags = { method: http_method.downcase! }
method_tags = { method: http_method.downcase }
tracker.increment "rack.request.method", tags: method_tags, inherit_tags: true
tracker.timing "rack.request.method.time", duration, tags: method_tags, inherit_tags: true
EOS
Expand Down
7 changes: 7 additions & 0 deletions test/integration/request_test.rb
Expand Up @@ -61,6 +61,13 @@ def test_track_http_method_info
assert_equal 1, aggregate.fetch("rack.request.method.time", tags: @tags.merge({ method: "post" }))[:count]
end

def test_request_method_not_mutated
get '/', {}, {'REQUEST_METHOD' => "GET".freeze}

assert_equal 1, counters.fetch("rack.request.method", tags: @tags.merge({ method: "GET" }))[:value]
assert_equal 1, aggregate.fetch("rack.request.method.time", tags: @tags.merge({ method: "get" }))[:count]
end

def test_track_exceptions
begin
get '/exception'
Expand Down

0 comments on commit 4c5cd0c

Please sign in to comment.