diff options
author | Brennan Dunn <me@brennandunn.com> | 2008-08-28 07:53:29 -0400 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2008-08-28 12:29:49 -0700 |
commit | 9cc8c0a0a18163fb6ae0f66b2513c902d19459dc (patch) | |
tree | 1731a3f436612031aec1b812fe1e2fb5b4d7da44 /actionpack/test | |
parent | 7bdd5b768e51f74fa437d1cc8f3c36643364c4fe (diff) | |
download | rails-9cc8c0a0a18163fb6ae0f66b2513c902d19459dc.tar.gz rails-9cc8c0a0a18163fb6ae0f66b2513c902d19459dc.tar.bz2 rails-9cc8c0a0a18163fb6ae0f66b2513c902d19459dc.zip |
Routes may be restricted to lists of HTTP methods instead of a single method or :any.
[#407 state:resolved]
Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
Diffstat (limited to 'actionpack/test')
-rw-r--r-- | actionpack/test/controller/routing_test.rb | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/actionpack/test/controller/routing_test.rb b/actionpack/test/controller/routing_test.rb index 6cf134c26f..1a802c464f 100644 --- a/actionpack/test/controller/routing_test.rb +++ b/actionpack/test/controller/routing_test.rb @@ -1297,6 +1297,31 @@ uses_mocha 'LegacyRouteSet, Route, RouteSet and RouteLoading' do end end + def test_recognize_array_of_methods + begin + Object.const_set(:BooksController, Class.new(ActionController::Base)) + rs.draw do |r| + r.connect '/match', :controller => 'books', :action => 'get_or_post', :conditions => { :method => [:get, :post] } + r.connect '/match', :controller => 'books', :action => 'not_get_or_post' + end + + @request = ActionController::TestRequest.new + @request.env["REQUEST_METHOD"] = 'POST' + @request.request_uri = "/match" + assert_nothing_raised { rs.recognize(@request) } + assert_equal 'get_or_post', @request.path_parameters[:action] + + # have to recreate or else the RouteSet uses a cached version: + @request = ActionController::TestRequest.new + @request.env["REQUEST_METHOD"] = 'PUT' + @request.request_uri = "/match" + assert_nothing_raised { rs.recognize(@request) } + assert_equal 'not_get_or_post', @request.path_parameters[:action] + ensure + Object.send(:remove_const, :BooksController) rescue nil + end + end + def test_subpath_recognized Object.const_set(:SubpathBooksController, Class.new(ActionController::Base)) |