aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test/controller/redirect_test.rb
diff options
context:
space:
mode:
authorNando Vieira <fnando.vieira@gmail.com>2010-09-18 20:36:44 -0300
committerJosé Valim <jose.valim@gmail.com>2010-09-24 12:49:27 +0200
commit7223fe7faf26f717aee056942aadecc62e8f5cd9 (patch)
treefd9388dd3235575bffae31851b46941c41c256a1 /actionpack/test/controller/redirect_test.rb
parent275f922a23b780600a32f70de5b661371c8ffdf4 (diff)
downloadrails-7223fe7faf26f717aee056942aadecc62e8f5cd9.tar.gz
rails-7223fe7faf26f717aee056942aadecc62e8f5cd9.tar.bz2
rails-7223fe7faf26f717aee056942aadecc62e8f5cd9.zip
Make redirect_to accept blocks [#5643 state:resolved]
Signed-off-by: José Valim <jose.valim@gmail.com>
Diffstat (limited to 'actionpack/test/controller/redirect_test.rb')
-rw-r--r--actionpack/test/controller/redirect_test.rb38
1 files changed, 38 insertions, 0 deletions
diff --git a/actionpack/test/controller/redirect_test.rb b/actionpack/test/controller/redirect_test.rb
index c30921a928..b00142c92d 100644
--- a/actionpack/test/controller/redirect_test.rb
+++ b/actionpack/test/controller/redirect_test.rb
@@ -99,6 +99,19 @@ class RedirectController < ActionController::Base
redirect_to nil
end
+ def redirect_to_with_block
+ redirect_to proc { "http://www.rubyonrails.org/" }
+ end
+
+ def redirect_to_with_block_and_assigns
+ @url = "http://www.rubyonrails.org/"
+ redirect_to proc { @url }
+ end
+
+ def redirect_to_with_block_and_options
+ redirect_to proc { {:action => "hello_world"} }
+ end
+
def rescue_errors(e) raise e end
def rescue_action(e) raise end
@@ -252,6 +265,31 @@ class RedirectTest < ActionController::TestCase
get :redirect_to_nil
end
end
+
+ def test_redirect_to_with_block
+ get :redirect_to_with_block
+ assert_response :redirect
+ assert_redirected_to "http://www.rubyonrails.org/"
+ end
+
+ def test_redirect_to_with_block_and_assigns
+ get :redirect_to_with_block_and_assigns
+ assert_response :redirect
+ assert_redirected_to "http://www.rubyonrails.org/"
+ end
+
+ def test_redirect_to_with_block_and_accepted_options
+ with_routing do |set|
+ set.draw do
+ match ':controller/:action'
+ end
+
+ get :redirect_to_with_block_and_options
+
+ assert_response :redirect
+ assert_redirected_to "http://test.host/redirect/hello_world"
+ end
+ end
end
module ModuleTest