Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

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
  • Loading branch information...
commit 50e247443371630e03cb360867770170a76ecb8b 1 parent a3469ca
@jamis jamis authored
View
2  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
View
5 actionpack/lib/action_controller/assertions.rb
@@ -78,9 +78,8 @@ def assert_redirected_to(options = {}, message=nil)
[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)
View
10 actionpack/test/controller/action_pack_assertions_test.rb
@@ -20,6 +20,8 @@ def redirect_to_action() redirect_to :action => "flash_me", :id => 1, :params =>
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 @@ def test_assert_redirect_url_match_pattern
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
View
1  actionpack/test/controller/fake_controllers.rb
@@ -19,5 +19,6 @@ class NewsFeedController < ActionController::Base
end
ActionController::Routing::Routes.draw do |map|
+ map.route_one 'route_one', :controller => 'elsewhere', :action => 'flash_me'
map.connect ':controller/:action/:id'
end
Please sign in to comment.
Something went wrong with that request. Please try again.