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

Ticket #6684: fix_actioncontroller_base_render_text_handles_false_object-v2.diff

File fix_actioncontroller_base_render_text_handles_false_object-v2.diff, 1.3 kB (added by PotatoSalad, 10 months ago)

Updated version of the patch to work with rails trunk [8514]

  • actionpack/test/controller/render_test.rb

    old new  
    3737    render :text => "hello world" 
    3838  end 
    3939 
     40  def render_text_false 
     41    # Simulating a model returning a boolean attribute 
     42    render :text => "foo".blank? 
     43  end 
     44 
    4045  def render_json_hello_world 
    4146    render :json => {:hello => 'world'}.to_json 
    4247  end 
     
    233238    assert_equal "hello world", @response.body 
    234239  end 
    235240 
     241  def test_render_text_false 
     242    get :render_text_false 
     243    assert_equal false, @response.body 
     244  end 
     245 
    236246  def test_render_json 
    237247    get :render_json_hello_world 
    238248    assert_equal '{"hello": "world"}', @response.body 
  • actionpack/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]