Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Ticket #10272: redirect_to_nil_raises_action_controller_error.diff

File redirect_to_nil_raises_action_controller_error.diff, 1.3 kB (added by farleyknight, 6 months ago)

Changed error to the generic ActionControllerError

  • test/controller/redirect_test.rb

    old new  
    7777    redirect_to Workshop.new(5, true) 
    7878  end 
    7979 
     80  def redirect_to_nil 
     81    redirect_to nil 
     82  end 
     83 
    8084  def rescue_errors(e) raise e end 
    8185     
    8286  def rescue_action(e) raise end 
     
    215219    get :redirect_to_new_record 
    216220    assert_equal "http://test.host/workshops", redirect_to_url 
    217221  end 
     222 
     223  def test_redirect_to_nil 
     224    assert_raises(ActionController::ActionControllerError) do 
     225      get :redirect_to_nil 
     226    end 
     227  end 
     228 
    218229end 
    219230 
    220231module ModuleTest 
  • lib/action_controller/base.rb

    old new  
    10291029      # RedirectBackError will be raised. You may specify some fallback 
    10301030      # behavior for this case by rescuing RedirectBackError. 
    10311031      def redirect_to(options = {}, response_status = {}) #:doc:  
    1032          
     1032        raise ActionControllerError.new("Cannot redirect to nil!") if options.nil?  
     1033 
    10331034        if options.is_a?(Hash) && options[:status]  
    10341035          status = options.delete(:status)  
    10351036        elsif response_status[:status]