Permalink
Browse files

2-0-stable: Make assert_routing aware of the HTTP method used. Refere…

…nces #8039 [mpalmer]

Merging [8748]


git-svn-id: http://svn-commit.rubyonrails.org/rails/branches/2-0-stable@8836 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
1 parent a9113b8 commit 8e556e5d74ba6d54f1e6bacad04768dd66d95da8 @NZKoz NZKoz committed Feb 10, 2008
View
7 actionpack/lib/action_controller/assertions/routing_assertions.rb
@@ -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
View
7 actionpack/test/controller/test_test.rb
@@ -401,6 +401,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
View
4 activerecord/CHANGELOG
@@ -1,5 +1,9 @@
*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" })
+
+
* Ensure that modifying has_and_belongs_to_many actions clear the query cache. Closes #10840 [john.andrews]
* Fix issue where Table#references doesn't pass a :null option to a *_type attribute for polymorphic associations. Closes #10753 [railsjitsu]

0 comments on commit 8e556e5

Please sign in to comment.