diff options
author | Jakub Suder <jakub.suder@gmail.com> | 2010-08-29 16:10:31 +0200 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2010-09-07 11:33:10 -0700 |
commit | 2524cf404ce943eca8a5f2d173188fd0cf2ac8b9 (patch) | |
tree | 0d589e9e06623d0bda440b78ccd93a426c2e4807 /activerecord/test/cases | |
parent | 2e8a3d0f43d7b394873ce21396ae49feacb99a74 (diff) | |
download | rails-2524cf404ce943eca8a5f2d173188fd0cf2ac8b9.tar.gz rails-2524cf404ce943eca8a5f2d173188fd0cf2ac8b9.tar.bz2 rails-2524cf404ce943eca8a5f2d173188fd0cf2ac8b9.zip |
fixed some issues with JSON encoding
- as_json in ActiveModel should return a hash
and handle :only/:except/:methods options
- Array and Hash should call as_json on their elements
- json methods should not modify options argument
[#5374 state:committed]
Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
Diffstat (limited to 'activerecord/test/cases')
-rw-r--r-- | activerecord/test/cases/json_serialization_test.rb | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/activerecord/test/cases/json_serialization_test.rb b/activerecord/test/cases/json_serialization_test.rb index a5736b227d..5da7f9e1b9 100644 --- a/activerecord/test/cases/json_serialization_test.rb +++ b/activerecord/test/cases/json_serialization_test.rb @@ -82,6 +82,13 @@ class JsonSerializationTest < ActiveRecord::TestCase assert_match %r{"label":"Has cheezburger"}, methods_json assert_match %r{"favorite_quote":"Constraints are liberating"}, methods_json end + + def test_serializable_hash_should_not_modify_options_in_argument + options = { :only => :name } + @contact.serializable_hash(options) + + assert_nil options[:except] + end end class DatabaseConnectedJsonEncodingTest < ActiveRecord::TestCase |