Skip to content

Commit

Permalink
Fix header Content-Type: #<Mime::NullType:...> in localized template
Browse files Browse the repository at this point in the history
This PR fixes #13064 regression bug introduced by the #8085

Now in _process_format when the format is a Mime::NullType nothing is written in self.content_type.
In this way the method Response#assign_default_content_type_and_charset can
write the the default mime_type.
  • Loading branch information
acapilleri committed Dec 3, 2013
1 parent 6eba8d2 commit 43962d6
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 1 deletion.
9 changes: 9 additions & 0 deletions actionpack/CHANGELOG.md
@@ -1,3 +1,12 @@
* Fix header Content-Type: #<Mime::NullType:...> in localized template

When localized template has no format in the template name,
now the response has the default and correct `content-type`.

Fix #13064.

*Angelo Capilleri*

* Better error message for typos in assert_response argument. * Better error message for typos in assert_response argument.


When the response type argument to `assert_response` is not a known When the response type argument to `assert_response` is not a known
Expand Down
2 changes: 1 addition & 1 deletion actionpack/lib/action_controller/metal/rendering.rb
Expand Up @@ -34,7 +34,7 @@ def render_to_body(options = {})


def _process_format(format) def _process_format(format)
super super
self.content_type ||= format.to_s self.content_type ||= format.to_s unless format.nil? #here test if format is Mime::NullTye istance, no if is a NillClass or FalseClass
end end


# Normalize arguments by catching blocks and setting them on :update. # Normalize arguments by catching blocks and setting them on :update.
Expand Down
11 changes: 11 additions & 0 deletions actionpack/test/controller/localized_templates_test.rb
Expand Up @@ -34,4 +34,15 @@ def test_use_fallback_locales
get :hello_world get :hello_world
assert_equal "Gutten Tag", @response.body assert_equal "Gutten Tag", @response.body
end end

def test_localized_template_has_correct_header_with_no_format_in_template_name
old_locale = I18n.locale
I18n.locale = :it

get :hello_world
assert_equal "Ciao Mondo", @response.body
assert_equal "text/html", @response.content_type
ensure
I18n.locale = old_locale
end
end end
1 change: 1 addition & 0 deletions actionpack/test/fixtures/localized/hello_world.it.erb
@@ -0,0 +1 @@
Ciao Mondo

0 comments on commit 43962d6

Please sign in to comment.