diff options
-rw-r--r-- | actionpack/CHANGELOG | 3 | ||||
-rw-r--r-- | actionpack/lib/action_controller/assertions/routing_assertions.rb | 7 | ||||
-rw-r--r-- | actionpack/test/controller/test_test.rb | 7 |
3 files changed, 15 insertions, 2 deletions
diff --git a/actionpack/CHANGELOG b/actionpack/CHANGELOG index cd4ffe06ca..3cf0abc6c7 100644 --- a/actionpack/CHANGELOG +++ b/actionpack/CHANGELOG @@ -1,5 +1,8 @@ *SVN* +* Make assert_routing aware of the HTTP method used. #8039 [mpalmer] + e.g. assert_routing({ :method => 'put', :path => '/product/321' }, { :controller => "product", :action => "update", :id => "321" }) + * Make map.root accept a single symbol as an argument to declare an alias. #10818 [bscofield] e.g. map.dashboard '/dashboard', :controller=>'dashboard' diff --git a/actionpack/lib/action_controller/assertions/routing_assertions.rb b/actionpack/lib/action_controller/assertions/routing_assertions.rb index 9bff283245..2acd003243 100644 --- a/actionpack/lib/action_controller/assertions/routing_assertions.rb +++ b/actionpack/lib/action_controller/assertions/routing_assertions.rb @@ -114,6 +114,9 @@ module ActionController # # # Tests a route, providing a defaults hash # assert_routing 'controller/action/9', {:id => "9", :item => "square"}, {:controller => "controller", :action => "action"}, {}, {:item => "square"} + # + # # Tests a route with a HTTP method + # assert_routing({ :method => 'put', :path => '/product/321' }, { :controller => "product", :action => "update", :id => "321" }) def assert_routing(path, options, defaults={}, extras={}, message=nil) assert_recognizes(options, path, extras, message) @@ -122,7 +125,7 @@ module ActionController options[:controller] = "/#{controller}" end - assert_generates(path, options, defaults, extras, message) + assert_generates(path.is_a?(Hash) ? path[:path] : path, options, defaults, extras, message) end private @@ -140,4 +143,4 @@ module ActionController end end end -end
\ No newline at end of file +end diff --git a/actionpack/test/controller/test_test.rb b/actionpack/test/controller/test_test.rb index b3a8e8750b..806fe32cd4 100644 --- a/actionpack/test/controller/test_test.rb +++ b/actionpack/test/controller/test_test.rb @@ -374,6 +374,13 @@ XML assert_routing 'content', :controller => 'content', :action => 'index' end + def test_assert_routing_with_method + with_routing do |set| + set.draw { |map| map.resources(:content) } + assert_routing({ :method => 'post', :path => 'content' }, { :controller => 'content', :action => 'create' }) + end + end + def test_assert_routing_in_module assert_routing 'admin/user', :controller => 'admin/user', :action => 'index' end |