From 526c69b49e36892af3ad7833e479de0a0fa6f278 Mon Sep 17 00:00:00 2001 From: Rick Olson Date: Sat, 22 Apr 2006 15:08:25 +0000 Subject: Diff compared options with #assert_redirected_to [Rick] git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4248 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- .../test/controller/action_pack_assertions_test.rb | 38 +++++++++++++++++++--- actionpack/test/controller/redirect_test.rb | 10 +++--- actionpack/test/controller/test_test.rb | 11 +++++-- 3 files changed, 47 insertions(+), 12 deletions(-) (limited to 'actionpack/test') diff --git a/actionpack/test/controller/action_pack_assertions_test.rb b/actionpack/test/controller/action_pack_assertions_test.rb index b359750d16..aae690d266 100644 --- a/actionpack/test/controller/action_pack_assertions_test.rb +++ b/actionpack/test/controller/action_pack_assertions_test.rb @@ -226,12 +226,41 @@ class ActionPackAssertionsControllerTest < Test::Unit::TestCase # test the redirection to a named route def test_assert_redirect_to_named_route - process :redirect_to_named_route - assert_raise(Test::Unit::AssertionFailedError) do - assert_redirected_to 'http://test.host/route_two' + with_routing do |set| + set.draw do + set.route_one 'route_one', :controller => 'action_pack_assertions', :action => 'nothing' + set.connect ':controller/:action/:id' + end + process :redirect_to_named_route + assert_redirected_to 'http://test.host/route_one' + assert_redirected_to route_one_url + assert_redirected_to :route_one end end - + + def test_assert_redirect_to_named_route_failure + with_routing do |set| + set.draw do + set.route_one 'route_one', :controller => 'action_pack_assertions', :action => 'nothing', :id => 'one' + set.route_two 'route_two', :controller => 'action_pack_assertions', :action => 'nothing', :id => 'two' + set.connect ':controller/:action/:id' + end + process :redirect_to_named_route + assert_raise(Test::Unit::AssertionFailedError) do + assert_redirected_to 'http://test.host/route_two' + end + assert_raise(Test::Unit::AssertionFailedError) do + assert_redirected_to :controller => 'action_pack_assertions', :action => 'nothing', :id => 'two' + end + assert_raise(Test::Unit::AssertionFailedError) do + assert_redirected_to route_two_url + end + assert_raise(Test::Unit::AssertionFailedError) do + assert_redirected_to :route_two + end + end + end + # test the flash-based assertions with something is in the flash def test_flash_assertions_full process :flash_me @@ -321,7 +350,6 @@ class ActionPackAssertionsControllerTest < Test::Unit::TestCase assert_flash_equal 'my name is inigo montoya...', 'hello' end - # check if we were rendered by a file-based template? def test_rendered_action process :nothing diff --git a/actionpack/test/controller/redirect_test.rb b/actionpack/test/controller/redirect_test.rb index d9b9042d5a..84f031923d 100755 --- a/actionpack/test/controller/redirect_test.rb +++ b/actionpack/test/controller/redirect_test.rb @@ -64,11 +64,11 @@ class RedirectTest < Test::Unit::TestCase assert_redirected_to :action => "other_host", :only_path => true rescue Test::Unit::AssertionFailedError => err redirection_msg, diff_msg = err.message.scan(/<\{[^\}]+\}>/).collect { |s| s[2..-3] } - assert_match %r(:only_path=>false), redirection_msg - assert_match %r(:host=>"other.test.host"), redirection_msg - assert_match %r(:action=>"other_host"), redirection_msg - assert_match %r(:only_path=>true), diff_msg - assert_match %r(:host=>"other.test.host"), diff_msg + assert_match %r("only_path"=>false), redirection_msg + assert_match %r("host"=>"other.test.host"), redirection_msg + assert_match %r("action"=>"other_host"), redirection_msg + assert_match %r("only_path"=>true), diff_msg + assert_match %r("host"=>"other.test.host"), diff_msg end end diff --git a/actionpack/test/controller/test_test.rb b/actionpack/test/controller/test_test.rb index 88e0c159a7..2d33a3d9d4 100644 --- a/actionpack/test/controller/test_test.rb +++ b/actionpack/test/controller/test_test.rb @@ -405,7 +405,14 @@ HTML end def test_assert_redirected_to_symbol - get :redirect_to_symbol - assert_redirected_to :generate_url + with_routing do |set| + set.draw do + set.generate_url 'foo', :controller => 'test' + set.connect ':controller/:action/:id' + end + + get :redirect_to_symbol + assert_redirected_to :generate_url + end end end -- cgit v1.2.3