aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPiotr Sarnacki <drogus@gmail.com>2012-03-02 12:46:24 -0200
committerSantiago Pastorino <santiago@wyeworks.com>2012-03-02 12:46:50 -0200
commitaeeebe1fdca56d20a9950f5585d10f8089388278 (patch)
treea803090b35d00044c70026aa72749d4672447160
parent974a9dbaa307a1b2ed79633366270aeeac778cd4 (diff)
downloadrails-aeeebe1fdca56d20a9950f5585d10f8089388278.tar.gz
rails-aeeebe1fdca56d20a9950f5585d10f8089388278.tar.bz2
rails-aeeebe1fdca56d20a9950f5585d10f8089388278.zip
Fix #5238, rendered_format is not set when template is not rendered
-rw-r--r--actionpack/lib/action_view/renderer/partial_renderer.rb2
-rw-r--r--actionpack/test/controller/render_test.rb8
2 files changed, 8 insertions, 2 deletions
diff --git a/actionpack/lib/action_view/renderer/partial_renderer.rb b/actionpack/lib/action_view/renderer/partial_renderer.rb
index 3033294883..3628b935b7 100644
--- a/actionpack/lib/action_view/renderer/partial_renderer.rb
+++ b/actionpack/lib/action_view/renderer/partial_renderer.rb
@@ -272,6 +272,8 @@ module ActionView
@block = block
@details = extract_details(options)
+ @lookup_context.rendered_format ||= formats.first
+
if String === partial
@object = options[:object]
@path = partial
diff --git a/actionpack/test/controller/render_test.rb b/actionpack/test/controller/render_test.rb
index e040878b26..8167fc2fd2 100644
--- a/actionpack/test/controller/render_test.rb
+++ b/actionpack/test/controller/render_test.rb
@@ -1246,22 +1246,26 @@ class RenderTest < ActionController::TestCase
def test_partial_only
get :partial_only
assert_equal "only partial", @response.body
+ assert_equal "text/html", @response.content_type
end
def test_should_render_html_formatted_partial
get :partial
- assert_equal 'partial html', @response.body
+ assert_equal "partial html", @response.body
+ assert_equal "text/html", @response.content_type
end
def test_should_render_html_partial_with_formats
get :partial_formats_html
- assert_equal 'partial html', @response.body
+ assert_equal "partial html", @response.body
+ assert_equal "text/html", @response.content_type
end
def test_render_to_string_partial
get :render_to_string_with_partial
assert_equal "only partial", assigns(:partial_only)
assert_equal "Hello: david", assigns(:partial_with_locals)
+ assert_equal "text/html", @response.content_type
end
def test_partial_with_counter