diff options
author | Jatinder Singh <jatinder.saundh@gmail.com> | 2010-04-30 21:02:11 -0700 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2010-05-04 13:17:26 -0700 |
commit | bce2c0ce37cbd4abb45ca36362fbb8fae3bbc6b9 (patch) | |
tree | 48f360dd477b96d1a9816c529971268575f62e18 /activemodel/test/cases/serializeration | |
parent | 7aad851c2e0d4579aa33a54a069a767b53cca406 (diff) | |
download | rails-bce2c0ce37cbd4abb45ca36362fbb8fae3bbc6b9.tar.gz rails-bce2c0ce37cbd4abb45ca36362fbb8fae3bbc6b9.tar.bz2 rails-bce2c0ce37cbd4abb45ca36362fbb8fae3bbc6b9.zip |
Active Model JSON serializer now supports custom root option
[#4515 state:committed]
Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
Diffstat (limited to 'activemodel/test/cases/serializeration')
-rw-r--r-- | activemodel/test/cases/serializeration/json_serialization_test.rb | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/activemodel/test/cases/serializeration/json_serialization_test.rb b/activemodel/test/cases/serializeration/json_serialization_test.rb index 81df52fcb9..7e89815c96 100644 --- a/activemodel/test/cases/serializeration/json_serialization_test.rb +++ b/activemodel/test/cases/serializeration/json_serialization_test.rb @@ -37,6 +37,22 @@ class JsonSerializationTest < ActiveModel::TestCase end end + test "should include custom root in json" do + begin + Contact.include_root_in_json = true + json = @contact.to_json(:root => 'json_contact') + + assert_match %r{^\{"json_contact":\{}, json + assert_match %r{"name":"Konata Izumi"}, json + assert_match %r{"age":16}, json + assert json.include?(%("created_at":#{ActiveSupport::JSON.encode(Time.utc(2006, 8, 1))})) + assert_match %r{"awesome":true}, json + assert_match %r{"preferences":\{"shows":"anime"\}}, json + ensure + Contact.include_root_in_json = false + end + end + test "should encode all encodable attributes" do json = @contact.to_json |