提交 92120426 编写于 作者: G Guo Xiang Tan

Improve router test.

We should assert that routes will not be recognized if the verbs do
not match.
上级 d3eb92d9
......@@ -544,19 +544,24 @@ def test_recognize_head_request_as_get_route
def test_recognize_cares_about_verbs
path = Path::Pattern.from_string "/books(/:action(.:format))"
app = Object.new
conditions = {
:request_method => 'GET'
}
conditions = { request_method: 'GET' }
@router.routes.add_route(app, path, conditions, {})
env = rails_env 'PATH_INFO' => '/books/list.rss',
"REQUEST_METHOD" => "POST"
called = false
@router.recognize(env) do |r, params|
called = true
end
assert_not called
conditions = conditions.dup
conditions[:request_method] = 'POST'
post = @router.routes.add_route(app, path, conditions, {})
env = rails_env 'PATH_INFO' => '/books/list.rss',
"REQUEST_METHOD" => "POST"
called = false
@router.recognize(env) do |r, params|
assert_equal post, r
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册