Permalink
Browse files

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

  • Loading branch information...
2 parents e59835b + f0b9e28 commit 6ae839bf488504cc2d3523700d5a49db1a89c76d @jeremy jeremy committed Apr 30, 2009
Showing with 12 additions and 1 deletion.
  1. +2 −1 actionpack/lib/action_controller/base/render.rb
  2. +10 −0 actionpack/test/controller/render_test.rb
@@ -253,7 +253,8 @@ def render(options = nil, extra_options = {}, &block) #:doc:
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
@@ -194,6 +194,10 @@ def accessing_controller_name_in_template
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 @@ def test_render_file_from_template
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

0 comments on commit 6ae839b

Please sign in to comment.