Skip to content

Commit

Permalink
Fix rails#5238, rendered_format is not set when template is not rendered
Browse files Browse the repository at this point in the history
  • Loading branch information
drogus authored and spastorino committed Mar 2, 2012
1 parent bbe7dac commit 1a71e84
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
2 changes: 2 additions & 0 deletions actionpack/lib/action_view/renderer/partial_renderer.rb
Expand Up @@ -273,6 +273,8 @@ def setup(context, options, block)
@block = block @block = block
@details = extract_details(options) @details = extract_details(options)


@lookup_context.rendered_format ||= formats.first

if String === partial if String === partial
@object = options[:object] @object = options[:object]
@path = partial @path = partial
Expand Down
8 changes: 6 additions & 2 deletions actionpack/test/controller/render_test.rb
Expand Up @@ -1241,22 +1241,26 @@ def test_using_layout_around_block_in_main_layout_and_within_content_for_layout
def test_partial_only def test_partial_only
get :partial_only get :partial_only
assert_equal "only partial", @response.body assert_equal "only partial", @response.body
assert_equal "text/html", @response.content_type
end end


def test_should_render_html_formatted_partial def test_should_render_html_formatted_partial
get :partial get :partial
assert_equal 'partial html', @response.body assert_equal "partial html", @response.body
assert_equal "text/html", @response.content_type
end end


def test_should_render_html_partial_with_formats def test_should_render_html_partial_with_formats
get :partial_formats_html get :partial_formats_html
assert_equal 'partial html', @response.body assert_equal "partial html", @response.body
assert_equal "text/html", @response.content_type
end end


def test_render_to_string_partial def test_render_to_string_partial
get :render_to_string_with_partial get :render_to_string_with_partial
assert_equal "only partial", assigns(:partial_only) assert_equal "only partial", assigns(:partial_only)
assert_equal "Hello: david", assigns(:partial_with_locals) assert_equal "Hello: david", assigns(:partial_with_locals)
assert_equal "text/html", @response.content_type
end end


def test_partial_with_counter def test_partial_with_counter
Expand Down

0 comments on commit 1a71e84

Please sign in to comment.