diff options
author | Matt Aimonetti <mattaimonetti@gmail.com> | 2011-09-22 14:05:25 -0700 |
---|---|---|
committer | Matt Aimonetti <mattaimonetti@gmail.com> | 2011-09-22 14:05:25 -0700 |
commit | 6e78bbea90f744fb7de3bc93752d1519503a370d (patch) | |
tree | 35d9da3b1a7bd4ce9bda148ecd04bad8c5841cfa /activemodel/test | |
parent | 8aa537c9452d40aeaf25e6d7e0c5bb1205b05d1a (diff) | |
download | rails-6e78bbea90f744fb7de3bc93752d1519503a370d.tar.gz rails-6e78bbea90f744fb7de3bc93752d1519503a370d.tar.bz2 rails-6e78bbea90f744fb7de3bc93752d1519503a370d.zip |
fixed a bug with the json serialization when the class setting is set to not include the root, but an instance is serialized with the root option passed as true
Diffstat (limited to 'activemodel/test')
-rw-r--r-- | activemodel/test/cases/serializers/json_serialization_test.rb | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/activemodel/test/cases/serializers/json_serialization_test.rb b/activemodel/test/cases/serializers/json_serialization_test.rb index 5e1e7d897a..40fdcf20ca 100644 --- a/activemodel/test/cases/serializers/json_serialization_test.rb +++ b/activemodel/test/cases/serializers/json_serialization_test.rb @@ -56,6 +56,16 @@ class JsonSerializationTest < ActiveModel::TestCase end end + test "should include root in json (option) even if the default is set to false" do + begin + Contact.include_root_in_json = false + json = @contact.to_json(:root => true) + assert_match %r{^\{"contact":\{}, json + ensure + Contact.include_root_in_json = true + end + end + test "should not include root in json (option)" do json = @contact.to_json(:root => false) |