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

Ticket #6684: fix_actioncontroller_base_render_text_handles_false_object.better_tests.diff

File fix_actioncontroller_base_render_text_handles_false_object.better_tests.diff, 1.4 kB (added by chuyeow, 10 months ago)
  • test/controller/render_test.rb

    old new  
    5757    render :text => "hello world", :status => 404 
    5858  end 
    5959 
     60  def render_text_with_nil 
     61    render :text => nil 
     62  end 
     63 
     64  def render_text_with_false 
     65    render :text => false 
     66  end 
     67 
    6068  def render_nothing_with_appendix 
    6169    render :text => "appended" 
    6270  end 
     
    263271    assert_equal 'hello world', @response.body 
    264272  end 
    265273 
     274  def test_render_text_with_nil 
     275    get :render_text_with_nil 
     276    assert_response 200 
     277    assert_equal '', @response.body 
     278  end 
     279 
     280  def test_render_text_with_false 
     281    get :render_text_with_false 
     282    assert_equal 'false', @response.body 
     283  end 
     284 
    266285  def test_render_nothing_with_appendix 
    267286    get :render_nothing_with_appendix 
    268287    assert_response 200 
  • lib/action_controller/base.rb

    old new  
    850850          response.headers["Location"] = url_for(location) 
    851851        end 
    852852 
    853         if text = options[:text] 
    854           render_for_text(text, options[:status]) 
     853        if options.has_key?(:text) 
     854          render_for_text(options[:text], options[:status]) 
    855855 
    856856        else 
    857857          if file = options[:file]