aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Koziarski <michael@koziarski.com>2008-01-12 03:09:39 +0000
committerMichael Koziarski <michael@koziarski.com>2008-01-12 03:09:39 +0000
commit7501451d7f417a304a56ac65f0b203c942920732 (patch)
tree8d896488bd8e275016f9c3ae3559d76a2c9bdf61
parentfb63fc67fb8210fede6fea1837fd6a9c69fa499f (diff)
downloadrails-7501451d7f417a304a56ac65f0b203c942920732.tar.gz
rails-7501451d7f417a304a56ac65f0b203c942920732.tar.bz2
rails-7501451d7f417a304a56ac65f0b203c942920732.zip
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
-rwxr-xr-xactionpack/lib/action_controller/base.rb3
-rwxr-xr-xactionpack/test/controller/redirect_test.rb11
2 files changed, 13 insertions, 1 deletions
diff --git a/actionpack/lib/action_controller/base.rb b/actionpack/lib/action_controller/base.rb
index d419a09ec5..b0f713b049 100755
--- a/actionpack/lib/action_controller/base.rb
+++ b/actionpack/lib/action_controller/base.rb
@@ -1029,7 +1029,8 @@ module ActionController #:nodoc:
# 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]
diff --git a/actionpack/test/controller/redirect_test.rb b/actionpack/test/controller/redirect_test.rb
index 5642792ca2..571d5b1f5a 100755
--- a/actionpack/test/controller/redirect_test.rb
+++ b/actionpack/test/controller/redirect_test.rb
@@ -77,6 +77,10 @@ class RedirectController < ActionController::Base
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 @@ class RedirectTest < Test::Unit::TestCase
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