Skip to content

Commit

Permalink
Fix #inspect failures when dealing with requests with method=nil.
Browse files Browse the repository at this point in the history
When I was debugging `ActionDispatch::Request` instances in some tests, I
noticed IRB complaining that the object did not support `#inspect`, as
it was trying to print out the `method` which calls `check_method(nil)`
which fails. Don't try to validate `nil` method as it will always fail
and appears to be a valid state (when constructing an empty request as in
some tests).
  • Loading branch information
ioquatix committed Jan 20, 2023
1 parent 5b9a246 commit cc3f507
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion actionpack/lib/action_dispatch/http/request.rb
Expand Up @@ -450,7 +450,10 @@ def commit_csrf_token

private
def check_method(name)
HTTP_METHOD_LOOKUP[name] || raise(ActionController::UnknownHttpMethod, "#{name}, accepted HTTP methods are #{HTTP_METHODS[0...-1].join(', ')}, and #{HTTP_METHODS[-1]}")
if name
HTTP_METHOD_LOOKUP[name] || raise(ActionController::UnknownHttpMethod, "#{name}, accepted HTTP methods are #{HTTP_METHODS[0...-1].join(', ')}, and #{HTTP_METHODS[-1]}")
end

name
end

Expand Down

0 comments on commit cc3f507

Please sign in to comment.