render_to_string must ensure that response_body

is nil

[ #5875 state:resolved]

Signed-off-by: José Valim <jose.valim@gmail.com>
This commit is contained in:
Neeraj Singh 2011-01-21 19:13:58 -05:00 committed by José Valim
parent c1145d9281
commit 806e6f80dc
2 changed files with 11 additions and 1 deletions

View File

@ -113,7 +113,7 @@ module AbstractController
def render_to_string(*args, &block)
options = _normalize_args(*args, &block)
_normalize_options(options)
render_to_body(options)
render_to_body(options).tap { self.response_body = nil }
end
# Raw rendering of a template to a Rack-compatible body.

View File

@ -26,6 +26,10 @@ class RenderJsonTest < ActionController::TestCase
render :json => nil
end
def render_json_render_to_string
render :text => render_to_string(:json => '[]')
end
def render_json_hello_world
render :json => ActiveSupport::JSON.encode(:hello => 'world')
end
@ -76,6 +80,12 @@ class RenderJsonTest < ActionController::TestCase
assert_equal 'application/json', @response.content_type
end
def test_render_json_render_to_string
get :render_json_render_to_string
assert_equal '[]', @response.body
end
def test_render_json
get :render_json_hello_world
assert_equal '{"hello":"world"}', @response.body