aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test/dispatch/routing_test.rb
diff options
context:
space:
mode:
authorYehuda Katz <wycats@Yehuda-Katz.local>2009-12-20 14:07:19 -0800
committerYehuda Katz <wycats@Yehuda-Katz.local>2009-12-20 14:07:32 -0800
commite48b4c2dd01877ace901e1c186d04605b53b40d0 (patch)
tree34573441a468cd7df3863a6ddf3526051380e763 /actionpack/test/dispatch/routing_test.rb
parent8b4735fbd9d5f6bd0c5d04688cc5edcd9b00ccf0 (diff)
downloadrails-e48b4c2dd01877ace901e1c186d04605b53b40d0.tar.gz
rails-e48b4c2dd01877ace901e1c186d04605b53b40d0.tar.bz2
rails-e48b4c2dd01877ace901e1c186d04605b53b40d0.zip
:to => redirect() can take a String using 1.9-style interpolation or proc that takes the path parameters as a Hash
Diffstat (limited to 'actionpack/test/dispatch/routing_test.rb')
-rw-r--r--actionpack/test/dispatch/routing_test.rb21
1 files changed, 21 insertions, 0 deletions
diff --git a/actionpack/test/dispatch/routing_test.rb b/actionpack/test/dispatch/routing_test.rb
index 425796b460..7145a0c530 100644
--- a/actionpack/test/dispatch/routing_test.rb
+++ b/actionpack/test/dispatch/routing_test.rb
@@ -24,6 +24,9 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest
match 'account/login', :to => redirect("/login")
+ match 'account/modulo/:name', :to => redirect("/%{name}s")
+ match 'account/proc/:name', :to => redirect {|params| "/#{params[:name].pluralize}" }
+
match 'openid/login', :via => [:get, :post], :to => "openid#login"
controller(:global) do
@@ -145,6 +148,24 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest
end
end
+ def test_redirect_modulo
+ with_test_routes do
+ get '/account/modulo/name'
+ assert_equal 301, @response.status
+ assert_equal 'http://www.example.com/names', @response.headers['Location']
+ assert_equal 'Moved Permanently', @response.body
+ end
+ end
+
+ def test_redirect_proc
+ with_test_routes do
+ get '/account/proc/person'
+ assert_equal 301, @response.status
+ assert_equal 'http://www.example.com/people', @response.headers['Location']
+ assert_equal 'Moved Permanently', @response.body
+ end
+ end
+
def test_openid
with_test_routes do
get '/openid/login'