diff options
author | Tom Ward <tom@popdog.net> | 2008-07-18 20:19:03 -0500 |
---|---|---|
committer | Joshua Peek <josh@joshpeek.com> | 2008-07-18 20:19:03 -0500 |
commit | d39485078ec56e25a96e97d44b53498d8a1c7426 (patch) | |
tree | 6c7a23d8c91536a8e79d38372d710baffc42c8d2 /actionpack/test/controller | |
parent | c3d1fda555c4bd5f8821d830c685ae5d0e7e52d0 (diff) | |
download | rails-d39485078ec56e25a96e97d44b53498d8a1c7426.tar.gz rails-d39485078ec56e25a96e97d44b53498d8a1c7426.tar.bz2 rails-d39485078ec56e25a96e97d44b53498d8a1c7426.zip |
Raise ArgumentError if an invalid method is specified as part of a route's conditions. Also raise an error if HEAD is specified as the method, as rails routes all HEAD requests through the equivalent GET, though doesn't return the response body [#182 state:resolved]
Signed-off-by: Joshua Peek <josh@joshpeek.com>
Diffstat (limited to 'actionpack/test/controller')
-rw-r--r-- | actionpack/test/controller/resources_test.rb | 20 | ||||
-rw-r--r-- | actionpack/test/controller/routing_test.rb | 16 |
2 files changed, 36 insertions, 0 deletions
diff --git a/actionpack/test/controller/resources_test.rb b/actionpack/test/controller/resources_test.rb index 0f7924649a..e153b0cc98 100644 --- a/actionpack/test/controller/resources_test.rb +++ b/actionpack/test/controller/resources_test.rb @@ -516,6 +516,26 @@ class ResourcesTest < Test::Unit::TestCase end end + def test_should_not_allow_invalid_head_method_for_member_routes + with_routing do |set| + set.draw do |map| + assert_raises(ArgumentError) do + map.resources :messages, :member => {:something => :head} + end + end + end + end + + def test_should_not_allow_invalid_http_methods_for_member_routes + with_routing do |set| + set.draw do |map| + assert_raises(ArgumentError) do + map.resources :messages, :member => {:something => :invalid} + end + end + end + end + def test_resource_action_separator with_routing do |set| set.draw do |map| diff --git a/actionpack/test/controller/routing_test.rb b/actionpack/test/controller/routing_test.rb index c5ccb71582..079189d7b3 100644 --- a/actionpack/test/controller/routing_test.rb +++ b/actionpack/test/controller/routing_test.rb @@ -1801,6 +1801,22 @@ uses_mocha 'LegacyRouteSet, Route, RouteSet and RouteLoading' do end end + def test_route_requirements_with_invalid_http_method_is_invalid + assert_raises ArgumentError do + set.draw do |map| + map.connect 'valid/route', :controller => 'pages', :action => 'show', :conditions => {:method => :invalid} + end + end + end + + def test_route_requirements_with_head_method_condition_is_invalid + assert_raises ArgumentError do + set.draw do |map| + map.connect 'valid/route', :controller => 'pages', :action => 'show', :conditions => {:method => :head} + end + end + end + def test_non_path_route_requirements_match_all set.draw do |map| map.connect 'page/37s', :controller => 'pages', :action => 'show', :name => /(jamis|david)/ |