aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test/controller/render_json_test.rb
diff options
context:
space:
mode:
authorwycats <wycats@gmail.com>2010-04-26 23:32:30 -0700
committerwycats <wycats@gmail.com>2010-04-26 23:32:30 -0700
commit91963e9e33eb5a28297323f1346aeb8b643e9d65 (patch)
tree0452dbaf63110fb5a19c958da50d4677dee11333 /actionpack/test/controller/render_json_test.rb
parentd5d717161d853d8d7240da59b41a879bdac6e982 (diff)
parentc1d73270717f30498f8f4d55d6695509107c2834 (diff)
downloadrails-91963e9e33eb5a28297323f1346aeb8b643e9d65.tar.gz
rails-91963e9e33eb5a28297323f1346aeb8b643e9d65.tar.bz2
rails-91963e9e33eb5a28297323f1346aeb8b643e9d65.zip
Merge branch 'master' of github.com:rails/rails
Diffstat (limited to 'actionpack/test/controller/render_json_test.rb')
-rw-r--r--actionpack/test/controller/render_json_test.rb18
1 files changed, 18 insertions, 0 deletions
diff --git a/actionpack/test/controller/render_json_test.rb b/actionpack/test/controller/render_json_test.rb
index 2580ada88b..5958b18d80 100644
--- a/actionpack/test/controller/render_json_test.rb
+++ b/actionpack/test/controller/render_json_test.rb
@@ -3,6 +3,14 @@ require 'controller/fake_models'
require 'pathname'
class RenderJsonTest < ActionController::TestCase
+ class JsonRenderable
+ def as_json(options={})
+ hash = { :a => :b, :c => :d, :e => :f }
+ hash.except!(*options[:except]) if options[:except]
+ hash
+ end
+ end
+
class TestController < ActionController::Base
protect_from_forgery
@@ -37,6 +45,10 @@ class RenderJsonTest < ActionController::TestCase
def render_json_with_render_to_string
render :json => {:hello => render_to_string(:partial => 'partial')}
end
+
+ def render_json_with_extra_options
+ render :json => JsonRenderable.new, :except => [:c, :e]
+ end
end
tests TestController
@@ -91,4 +103,10 @@ class RenderJsonTest < ActionController::TestCase
assert_equal '{"hello":"partial html"}', @response.body
assert_equal 'application/json', @response.content_type
end
+
+ def test_render_json_forwards_extra_options
+ get :render_json_with_extra_options
+ assert_equal '{"a":"b"}', @response.body
+ assert_equal 'application/json', @response.content_type
+ end
end