Skip to content

Commit

Permalink
Fix default rendered format problem when calling render method withou…
Browse files Browse the repository at this point in the history
…t :content_type option. Closes #11393.
  • Loading branch information
kennyj committed Jul 14, 2013
1 parent 9fbdd9d commit ca85cac
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
5 changes: 5 additions & 0 deletions actionview/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
2 changes: 1 addition & 1 deletion actionview/lib/action_view/renderer/template_renderer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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])
Expand Down
5 changes: 5 additions & 0 deletions actionview/test/template/render_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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])
Expand Down

0 comments on commit ca85cac

Please sign in to comment.