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

Ticket #9524: head_method_content_type_default.2.diff

File head_method_content_type_default.2.diff, 2.1 kB (added by danger, 1 year ago)

recreated original patch from the rails root directory

  • actionpack/test/controller/new_render_test.rb

    old new  
    251251  def head_with_location_header 
    252252    head :location => "/foo" 
    253253  end 
     254   
     255  def head_with_content_type_header 
     256    head :content_type => "text/enriched" 
     257  end 
    254258 
    255259  def head_with_symbolic_status 
    256260    head :status => params[:status].intern 
     
    799803    assert_equal "something", @response.headers["X-Custom-Header"] 
    800804    assert_response :forbidden 
    801805  end 
     806   
     807  def test_head_sets_content_type_header_to_text_plain_by_default 
     808    get :head_with_location_header 
     809    assert @response.body.blank? 
     810    assert_equal "text/plain", @response.content_type 
     811    assert_response :ok     
     812  end 
     813   
     814  def test_head_sets_content_type_header_to_value_supplied_in_options 
     815    get :head_with_content_type_header 
     816    assert @response.body.blank? 
     817    assert_equal "text/enriched", @response.content_type 
     818    assert_response :ok     
     819  end 
    802820 
    803821  def test_rendering_with_location_should_set_header 
    804822    get :render_with_location 
  • actionpack/test/controller/rescue_test.rb

    old new  
    115115 
    116116    assert_response :not_found 
    117117    assert_equal ' ', @response.body 
     118    assert_equal 'text/plain', @response.content_type 
    118119  end 
    119120 
    120121 
  • actionpack/lib/action_controller/base.rb

    old new  
    903903        end 
    904904 
    905905        raise ArgumentError, "head requires an options hash" if !options.is_a?(Hash) 
     906         
     907        options.reverse_merge!(:content_type => Mime::TEXT) 
    906908 
    907909        status = interpret_status(status || options.delete(:status) || :ok) 
    908910