Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge the fix for redirecting to nil. References #10272 [farleyknight]
git-svn-id: http://svn-commit.rubyonrails.org/rails/branches/2-0-stable@8634 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information
NZKoz committed Jan 12, 2008
1 parent 1752dcc commit f3b3826
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
3 changes: 2 additions & 1 deletion actionpack/lib/action_controller/base.rb
Expand Up @@ -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]
Expand Down
11 changes: 11 additions & 0 deletions actionpack/test/controller/redirect_test.rb
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit f3b3826

Please sign in to comment.