diff options
author | Guo Xiang Tan <tgx_world@hotmail.com> | 2014-07-04 12:04:52 -0700 |
---|---|---|
committer | Guo Xiang Tan <tgx_world@hotmail.com> | 2014-08-21 16:35:39 +0800 |
commit | 92120426317083ae90cb64cff07a7dd3a8acdc65 (patch) | |
tree | 3273b0fa45fb07c43cdefb3cd08c840b0edd241d /actionpack | |
parent | d3eb92d95a694905a80668dcde1fb49e2d08f388 (diff) | |
download | rails-92120426317083ae90cb64cff07a7dd3a8acdc65.tar.gz rails-92120426317083ae90cb64cff07a7dd3a8acdc65.tar.bz2 rails-92120426317083ae90cb64cff07a7dd3a8acdc65.zip |
Improve router test.
We should assert that routes will not be recognized if the verbs do
not match.
Diffstat (limited to 'actionpack')
-rw-r--r-- | actionpack/test/journey/router_test.rb | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/actionpack/test/journey/router_test.rb b/actionpack/test/journey/router_test.rb index 8fc965adf4..8e90d4100f 100644 --- a/actionpack/test/journey/router_test.rb +++ b/actionpack/test/journey/router_test.rb @@ -544,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 |