Permalink
Browse files

Make assert_routing aware of the HTTP method used. Closes #8039 [mpa…

…lmer]

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8748 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
1 parent 9623264 commit 900d6d7bd24519cbcab11b18ae42ae843e3b8aa9 @NZKoz NZKoz committed Jan 30, 2008
View
@@ -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'
@@ -114,6 +114,9 @@ def assert_generates(expected_path, options, defaults={}, extras = {}, message=n
#
# # 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 @@ def assert_routing(path, options, defaults={}, extras={}, message=nil)
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 @@ def recognized_request_for(path, request_method = nil)
end
end
end
-end
+end
@@ -374,6 +374,13 @@ def test_assert_routing
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

0 comments on commit 900d6d7

Please sign in to comment.