diff options
Diffstat (limited to 'actionpack/test/journey/router_test.rb')
-rw-r--r-- | actionpack/test/journey/router_test.rb | 38 |
1 files changed, 31 insertions, 7 deletions
diff --git a/actionpack/test/journey/router_test.rb b/actionpack/test/journey/router_test.rb index 2e7e8e1bea..8e90d4100f 100644 --- a/actionpack/test/journey/router_test.rb +++ b/actionpack/test/journey/router_test.rb @@ -503,6 +503,25 @@ module ActionDispatch assert called end + def test_recognize_head_route + path = Path::Pattern.from_string "/books(/:action(.:format))" + app = Object.new + conditions = { request_method: 'HEAD' } + @router.routes.add_route(app, path, conditions, {}) + + env = rails_env( + 'PATH_INFO' => '/books/list.rss', + 'REQUEST_METHOD' => 'HEAD' + ) + + called = false + @router.recognize(env) do |r, params| + called = true + end + + assert called + end + def test_recognize_head_request_as_get_route path = Path::Pattern.from_string "/books(/:action(.:format))" app = Object.new @@ -525,19 +544,24 @@ module ActionDispatch 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 @@ -561,7 +585,7 @@ module ActionDispatch end def rails_env env, klass = ActionDispatch::Request - klass.new env + klass.new(rack_env(env)) end def rack_env env |