diff options
author | kennyj <kennyj@gmail.com> | 2013-07-15 02:11:43 +0900 |
---|---|---|
committer | kennyj <kennyj@gmail.com> | 2013-07-15 02:11:43 +0900 |
commit | ca85caca0dd10f4e4950173094f8a0577cfe2560 (patch) | |
tree | 1a94bacea79fe119724dddf0508fd8ce4360ab1d /actionview | |
parent | 9fbdd9d83e8e2775845cbc581e0c357f99d292e4 (diff) | |
download | rails-ca85caca0dd10f4e4950173094f8a0577cfe2560.tar.gz rails-ca85caca0dd10f4e4950173094f8a0577cfe2560.tar.bz2 rails-ca85caca0dd10f4e4950173094f8a0577cfe2560.zip |
Fix default rendered format problem when calling render method without :content_type option. Closes #11393.
Diffstat (limited to 'actionview')
-rw-r--r-- | actionview/CHANGELOG.md | 5 | ||||
-rw-r--r-- | actionview/lib/action_view/renderer/template_renderer.rb | 2 | ||||
-rw-r--r-- | actionview/test/template/render_test.rb | 5 |
3 files changed, 11 insertions, 1 deletions
diff --git a/actionview/CHANGELOG.md b/actionview/CHANGELOG.md index 2981e76ec5..c5bb8fe627 100644 --- a/actionview/CHANGELOG.md +++ b/actionview/CHANGELOG.md @@ -1,3 +1,8 @@ +* Fix default rendered format problem when calling `render` without :content_type option. + It should return :html. Fix #11393. + + *Gleb Mazovetskiy* *Oleg* *kennyj* + * Fix `link_to` with block and url hashes. Before: diff --git a/actionview/lib/action_view/renderer/template_renderer.rb b/actionview/lib/action_view/renderer/template_renderer.rb index 4d5c5db80c..668831dff3 100644 --- a/actionview/lib/action_view/renderer/template_renderer.rb +++ b/actionview/lib/action_view/renderer/template_renderer.rb @@ -11,7 +11,7 @@ module ActionView 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]) diff --git a/actionview/test/template/render_test.rb b/actionview/test/template/render_test.rb index 8cffe73cce..928dfb092d 100644 --- a/actionview/test/template/render_test.rb +++ b/actionview/test/template/render_test.rb @@ -41,6 +41,11 @@ module RenderTestCases 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]) |