Permalink
Browse files

Fix assert_redirected_to so it works with symbols

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4004 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
1 parent 4941475 commit b0189f3f2ffd9de95ba2332cdcfaf48d28081e18 @jamis jamis committed Mar 20, 2006
Showing with 20 additions and 5 deletions.
  1. +2 −2 actionpack/lib/action_controller/assertions.rb
  2. +18 −3 actionpack/test/controller/test_test.rb
@@ -85,8 +85,8 @@ def assert_redirected_to(options = {}, message=nil)
assert_equal(eurl, url, msg) if eurl && url
assert_equal(epath, path, msg) if epath && path
else
- @response_diff = options.diff(@response.redirected_to) if @response.redirected_to
- msg = build_message(message, "response is not a redirection to all of the options supplied (redirection is <?>), difference: <?>",
+ @response_diff = options.diff(@response.redirected_to) if options.is_a?(Hash) && @response.redirected_to.is_a?(Hash)
+ msg = build_message(message, "response is not a redirection to all of the options supplied (redirection is <?>)#{', difference: <?>' if @response_diff}",
@response.redirected_to || @response.redirect_url, @response_diff)
assert_block(msg) do
@@ -7,7 +7,7 @@ def set_flash
flash["test"] = ">#{flash["test"]}<"
render :text => 'ignore me'
end
-
+
def render_raw_post
raise Test::Unit::AssertionFailedError, "#raw_post is blank" if request.raw_post.blank?
render :text => request.raw_post
@@ -54,9 +54,19 @@ def test_file_upload
render :text => params[:file].size
end
- def rescue_action(e)
- raise e
+ def redirect_to_symbol
+ redirect_to :generate_url, :id => 5
end
+
+ private
+
+ def rescue_action(e)
+ raise e
+ end
+
+ def generate_url(opts)
+ url_for(opts.merge(:action => "test_uri"))
+ end
end
def setup
@@ -393,4 +403,9 @@ def test_fixture_file_upload
def test_test_uploaded_file_exception_when_file_doesnt_exist
assert_raise(RuntimeError) { ActionController::TestUploadedFile.new('non_existent_file') }
end
+
+ def test_assert_redirected_to_symbol
+ get :redirect_to_symbol
+ assert_redirected_to :generate_url
+ end
end

0 comments on commit b0189f3

Please sign in to comment.