diff options
author | Jamis Buck <jamis@37signals.com> | 2005-08-06 08:37:25 +0000 |
---|---|---|
committer | Jamis Buck <jamis@37signals.com> | 2005-08-06 08:37:25 +0000 |
commit | 50e247443371630e03cb360867770170a76ecb8b (patch) | |
tree | b1fa8948ded0f06fa573247882c03c617fb1c9b2 | |
parent | a3469cadadfd770ad9029f651f3a51560bbd3045 (diff) | |
download | rails-50e247443371630e03cb360867770170a76ecb8b.tar.gz rails-50e247443371630e03cb360867770170a76ecb8b.tar.bz2 rails-50e247443371630e03cb360867770170a76ecb8b.zip |
Make assert_redirected_to properly check URL's passed as strings #1910 [Scott Barron]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1971 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
-rw-r--r-- | actionpack/CHANGELOG | 2 | ||||
-rw-r--r-- | actionpack/lib/action_controller/assertions.rb | 5 | ||||
-rw-r--r-- | actionpack/test/controller/action_pack_assertions_test.rb | 10 | ||||
-rw-r--r-- | actionpack/test/controller/fake_controllers.rb | 1 |
4 files changed, 15 insertions, 3 deletions
diff --git a/actionpack/CHANGELOG b/actionpack/CHANGELOG index b860ce3986..c55df53302 100644 --- a/actionpack/CHANGELOG +++ b/actionpack/CHANGELOG @@ -1,5 +1,7 @@ *SVN* +* Make assert_redirected_to properly check URL's passed as strings #1910 [Scott Barron] + * Make sure :layout => false is always used when rendering inside a layout * Use raise instead of assert_not_nil in Test::Unit::TestCase#process to ensure that the test variables (controller, request, response) have been set diff --git a/actionpack/lib/action_controller/assertions.rb b/actionpack/lib/action_controller/assertions.rb index bb81ffac75..ad70111f3b 100644 --- a/actionpack/lib/action_controller/assertions.rb +++ b/actionpack/lib/action_controller/assertions.rb @@ -78,9 +78,8 @@ module Test #:nodoc: [u, (p[0..0] == '/') ? p : '/' + p] end.flatten - if eurl && url then assert_equal(eurl, url, msg) - else assert_equal(epath, path, msg) - end + assert_equal(eurl, url, msg) if eurl && url + assert_equal(epath, path, msg) if epath && path else msg = build_message(message, "response is not a redirection to all of the options supplied (redirection is <?>)", @response.redirected_to || @response.redirect_url) diff --git a/actionpack/test/controller/action_pack_assertions_test.rb b/actionpack/test/controller/action_pack_assertions_test.rb index e7faeb25cd..917ae330b6 100644 --- a/actionpack/test/controller/action_pack_assertions_test.rb +++ b/actionpack/test/controller/action_pack_assertions_test.rb @@ -20,6 +20,8 @@ class ActionPackAssertionsController < ActionController::Base def redirect_to_controller() redirect_to :controller => "elsewhere", :action => "flash_me"; end def redirect_to_path() redirect_to '/some/path' end + + def redirect_to_named_route() redirect_to route_one_url end # a redirect to an external location def redirect_external() redirect_to_url "http://www.rubyonrails.org"; end @@ -185,6 +187,14 @@ class ActionPackAssertionsControllerTest < Test::Unit::TestCase process :redirect_external assert_redirect_url_match /ruby/ end + + # 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' + end + end # test the flash-based assertions with something is in the flash def test_flash_assertions_full diff --git a/actionpack/test/controller/fake_controllers.rb b/actionpack/test/controller/fake_controllers.rb index 43f933b0d8..28136e09e8 100644 --- a/actionpack/test/controller/fake_controllers.rb +++ b/actionpack/test/controller/fake_controllers.rb @@ -19,5 +19,6 @@ module Object::Controllers end ActionController::Routing::Routes.draw do |map| + map.route_one 'route_one', :controller => 'elsewhere', :action => 'flash_me' map.connect ':controller/:action/:id' end |