mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
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
This commit is contained in:
parent
fb63fc67fb
commit
7501451d7f
2 changed files with 13 additions and 1 deletions
|
@ -1029,6 +1029,7 @@ 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)
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue