Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #11438 from kennyj/fix_11393-40

Backport #11437 to 4-0-stable. Fix default rendered format when calling render method without :content_type option.
  • Loading branch information...
commit 87c71e59d5db52ae08b6fbfefd16c081900ec0b6 2 parents 4baddcc + bb6abbc
@guilleiguaran guilleiguaran authored
View
7 actionpack/CHANGELOG.md
@@ -1,5 +1,12 @@
## unreleased ##
+* Fix default rendered format problem when calling `render` without :content_type option.
+ It should return :html.
+
+ Fixes #11393
+
+ *Gleb Mazovetskiy* *Oleg* *kennyj*
+
* Fix `ActionDispatch::ParamsParser#parse_formatted_parameters` to rewind body input stream on
parsing json params.
View
2  actionpack/lib/action_view/renderer/template_renderer.rb
@@ -11,7 +11,7 @@ def render(context, options)
prepend_formats(template.formats)
unless context.rendered_format
- context.rendered_format = template.formats.first || formats.last
+ context.rendered_format = template.formats.first || formats.first
end
render_template(template, options[:layout], options[:locals])
View
5 actionpack/test/template/render_test.rb
@@ -41,6 +41,11 @@ def test_render_template_with_format
assert_match "<error>No Comment</error>", @view.render(:template => "comments/empty", :formats => [:xml])
end
+ def test_rendered_format_without_format
+ @view.render(:inline => "test")
+ assert_equal :html, @view.lookup_context.rendered_format
+ end
+
def test_render_partial_implicitly_use_format_of_the_rendered_template
@view.lookup_context.formats = [:json]
assert_equal "Hello world", @view.render(:template => "test/one", :formats => [:html])
Please sign in to comment.
Something went wrong with that request. Please try again.