Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

don't misbehave when redirecting to nil. Closes #10272 [farleyknight]

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8633 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
commit 7501451d7f417a304a56ac65f0b203c942920732 1 parent fb63fc6
Michael Koziarski NZKoz authored
3  actionpack/lib/action_controller/base.rb
View
@@ -1029,7 +1029,8 @@ def default_url_options(options) #:doc:
# RedirectBackError will be raised. You may specify some fallback
# behavior for this case by rescuing RedirectBackError.
def redirect_to(options = {}, response_status = {}) #:doc:
-
+ raise ActionControllerError.new("Cannot redirect to nil!") if options.nil?
+
if options.is_a?(Hash) && options[:status]
status = options.delete(:status)
elsif response_status[:status]
11 actionpack/test/controller/redirect_test.rb
View
@@ -77,6 +77,10 @@ def redirect_to_new_record
redirect_to Workshop.new(5, true)
end
+ def redirect_to_nil
+ redirect_to nil
+ end
+
def rescue_errors(e) raise e end
def rescue_action(e) raise end
@@ -215,6 +219,13 @@ def test_redirect_to_record
get :redirect_to_new_record
assert_equal "http://test.host/workshops", redirect_to_url
end
+
+ def test_redirect_to_nil
+ assert_raises(ActionController::ActionControllerError) do
+ get :redirect_to_nil
+ end
+ end
+
end
module ModuleTest
Please sign in to comment.
Something went wrong with that request. Please try again.