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

Ticket #6684: fix_actioncontroller_base_render_text_handles_false_object.diff

File fix_actioncontroller_base_render_text_handles_false_object.diff, 1.3 kB (added by tjennings, 2 years ago)

Patch to fix defect, with updated render_test.rb

  • test/controller/render_test.rb

    old new  
    4747    render_text "hello world" 
    4848    render_text ", goodbye!", "404 Not Found", true 
    4949  end 
     50   
     51  def render_text_false 
     52    # Simulating a model returning a boolean attribute 
     53    render :text => "foo".blank? 
     54  end 
    5055 
    5156  def render_nothing_with_appendix 
    5257    render_text "appended", nil, true 
     
    163168    get :render_text_hello_world 
    164169    assert_equal "hello world", @response.body 
    165170  end 
     171   
     172  def test_do_with_render_text_false 
     173    get :render_text_false 
     174    assert_equal false, @response.body 
     175  end 
    166176 
    167177  def test_do_with_render_custom_code 
    168178    get :render_custom_code 
  • lib/action_controller/base.rb

    old new  
    713713          response.content_type = content_type.to_s 
    714714        end 
    715715 
    716         if text = options[:text] 
    717           render_text(text, options[:status]) 
     716        if options.key?(:text) 
     717          render_text(options[:text], options[:status]) 
    718718 
    719719        else 
    720720          if file = options[:file]