mirror of https://github.com/rails/rails
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:
parent
c1145d9281
commit
806e6f80dc
|
@ -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.
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue