1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Merge branch 'master' of git@github.com:rails/rails

This commit is contained in:
Jeremy Kemper 2009-04-30 16:45:39 -07:00
commit 6ae839bf48
2 changed files with 12 additions and 1 deletions

View file

@ -253,7 +253,8 @@ module ActionController
response.content_type ||= Mime::JS
render_for_text(js)
elsif json = options[:json]
elsif options.include?(:json)
json = options[:json]
json = ActiveSupport::JSON.encode(json) unless json.respond_to?(:to_str)
json = "#{options[:callback]}(#{json})" unless options[:callback].blank?
response.content_type ||= Mime::JSON

View file

@ -194,6 +194,10 @@ class TestController < ActionController::Base
render :inline => "<%= controller_name %>"
end
def render_json_nil
render :json => nil
end
def render_json_hello_world
render :json => ActiveSupport::JSON.encode(:hello => 'world')
end
@ -874,6 +878,12 @@ class RenderTest < ActionController::TestCase
assert_equal "The secret is in the sauce\n", @response.body
end
def test_render_json_nil
get :render_json_nil
assert_equal 'null', @response.body
assert_equal 'application/json', @response.content_type
end
def test_render_json
get :render_json_hello_world
assert_equal '{"hello":"world"}', @response.body