提交 b6dd0c4d 编写于 作者: A Andrew White

Merge pull request #18764 from tsun1215/master

Explicitly ignored wildcard verbs from head_routes
* Explicitly ignored wildcard verbs when searching for HEAD routes before fallback
Fixes an issue where a mounted rack app at root would intercept the HEAD
request causing an incorrect behavior during the fall back to GET requests.
Example:
```ruby
draw do
get '/home' => 'test#index'
mount rack_app, at: '/'
end
head '/home'
assert_response :success
```
In this case, a HEAD request runs through the routes the first time and fails
to match anything. Then, it runs through the list with the fallback and matches
`get '/home'`. The original behavior would match the rack app in the first pass.
*Terence Sun*
* Migrating xhr methods to keyword arguments syntax
in `ActionController::TestCase` and `ActionDispatch::Integration`
......
......@@ -121,6 +121,7 @@ def find_routes req
end
def match_head_routes(routes, req)
routes.delete_if { |route| route.verb == // }
head_routes = match_routes(routes, req)
if head_routes.empty?
......
......@@ -3477,6 +3477,18 @@ def test_scope_where_as_is_empty
assert_equal '/post/comments/new', new_comment_path
end
def test_head_fetch_with_mount_on_root
draw do
get '/home' => 'test#index'
mount lambda { |env| [404, {"Content-Type" => "text/html"}, ["testing"]] }, at: '/'
end
head '/home'
assert_response :success
head '/'
assert_response :not_found
end
private
def draw(&block)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册