mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Merge pull request #28937 from maclover7/jm-fix-28927
Default content type for `head` is `text/html`
This commit is contained in:
commit
b66bf91316
2 changed files with 15 additions and 1 deletions
|
@ -38,7 +38,7 @@ module ActionController
|
||||||
self.response_body = ""
|
self.response_body = ""
|
||||||
|
|
||||||
if include_content?(response_code)
|
if include_content?(response_code)
|
||||||
self.content_type = content_type || (Mime[formats.first] if formats)
|
self.content_type = content_type || (Mime[formats.first] if formats) || Mime[:html]
|
||||||
response.charset = false
|
response.charset = false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -250,6 +250,15 @@ class TestController < ActionController::Base
|
||||||
head 204
|
head 204
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def head_default_content_type
|
||||||
|
# simulating path like "/1.foobar"
|
||||||
|
request.formats = []
|
||||||
|
|
||||||
|
respond_to do |format|
|
||||||
|
format.any { head 200 }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def set_variable_for_layout
|
def set_variable_for_layout
|
||||||
|
@ -814,6 +823,11 @@ class HeadRenderTest < ActionController::TestCase
|
||||||
get :head_and_return
|
get :head_and_return
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_head_default_content_type
|
||||||
|
post :head_default_content_type
|
||||||
|
assert_equal "text/html", @response.header["Content-Type"]
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
class HttpCacheForeverTest < ActionController::TestCase
|
class HttpCacheForeverTest < ActionController::TestCase
|
||||||
|
|
Loading…
Reference in a new issue