Skip to content
This repository
Browse code

Backport #11437 to 4-0-stable. Fix default rendered format when calli…

…ng render method without :content_type option.
  • Loading branch information...
commit bb6abbc2bd51d43f3c0f06c97cb3def03eae8241 1 parent 4baddcc
Toshinori Kajihara authored
7  actionpack/CHANGELOG.md
Source Rendered
... ...
@@ -1,5 +1,12 @@
1 1
 ## unreleased ##
2 2
 
  3
+*   Fix default rendered format problem when calling `render` without :content_type option.
  4
+    It should return :html.
  5
+
  6
+    Fixes #11393
  7
+
  8
+    *Gleb Mazovetskiy* *Oleg* *kennyj*
  9
+
3 10
 *   Fix `ActionDispatch::ParamsParser#parse_formatted_parameters` to rewind body input stream on
4 11
     parsing json params.
5 12
 
2  actionpack/lib/action_view/renderer/template_renderer.rb
@@ -11,7 +11,7 @@ def render(context, options)
11 11
       prepend_formats(template.formats)
12 12
 
13 13
       unless context.rendered_format
14  
-        context.rendered_format = template.formats.first || formats.last
  14
+        context.rendered_format = template.formats.first || formats.first
15 15
       end
16 16
 
17 17
       render_template(template, options[:layout], options[:locals])
5  actionpack/test/template/render_test.rb
@@ -41,6 +41,11 @@ def test_render_template_with_format
41 41
     assert_match "<error>No Comment</error>", @view.render(:template => "comments/empty", :formats => [:xml])
42 42
   end
43 43
 
  44
+  def test_rendered_format_without_format
  45
+    @view.render(:inline => "test")
  46
+    assert_equal :html, @view.lookup_context.rendered_format
  47
+  end
  48
+
44 49
   def test_render_partial_implicitly_use_format_of_the_rendered_template
45 50
     @view.lookup_context.formats = [:json]
46 51
     assert_equal "Hello world", @view.render(:template => "test/one", :formats => [:html])

0 notes on commit bb6abbc

Please sign in to comment.
Something went wrong with that request. Please try again.