Permalink
Browse files

Merge branch 'format_localized_template' of https://github.com/acapil…

…leri/rails

Conflicts:
	actionpack/CHANGELOG.md
  • Loading branch information...
2 parents c48a0ca + 43962d6 commit 9ed3aab6927471078888ff51c255561350946344 @guilleiguaran guilleiguaran committed Dec 3, 2013
View
9 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*
+
* Try to escape each part of a url correctly when using a redirect route.
Fixes #13110.
View
2 actionpack/lib/action_controller/metal/rendering.rb
@@ -34,7 +34,7 @@ def render_to_body(options = {})
def _process_format(format)
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
# Normalize arguments by catching blocks and setting them on :update.
View
11 actionpack/test/controller/localized_templates_test.rb
@@ -34,4 +34,15 @@ def test_use_fallback_locales
get :hello_world
assert_equal "Gutten Tag", @response.body
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
View
1 actionpack/test/fixtures/localized/hello_world.it.erb
@@ -0,0 +1 @@
+Ciao Mondo

0 comments on commit 9ed3aab

Please sign in to comment.