diff options
author | Mike Mangino <mmangino@hubtran.com> | 2017-03-03 15:02:35 -0500 |
---|---|---|
committer | Mike Mangino <mmangino@hubtran.com> | 2017-03-03 15:02:35 -0500 |
commit | 1bb0605dfe09f654d9ad43a86b69183cd6f653f2 (patch) | |
tree | b140192eeb3fadc1628d627f008602c560cc2f04 /activemodel/test | |
parent | 76be78c59cd75eaafb31719745b43df4743fd33d (diff) | |
download | rails-1bb0605dfe09f654d9ad43a86b69183cd6f653f2.tar.gz rails-1bb0605dfe09f654d9ad43a86b69183cd6f653f2.tar.bz2 rails-1bb0605dfe09f654d9ad43a86b69183cd6f653f2.zip |
Don't accidentally lose includes in serialization
Diffstat (limited to 'activemodel/test')
-rw-r--r-- | activemodel/test/cases/serialization_test.rb | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/activemodel/test/cases/serialization_test.rb b/activemodel/test/cases/serialization_test.rb index f78efd2f0c..3446742d8c 100644 --- a/activemodel/test/cases/serialization_test.rb +++ b/activemodel/test/cases/serialization_test.rb @@ -144,6 +144,12 @@ class SerializationTest < ActiveModel::TestCase assert_equal expected, @user.serializable_hash(include: { address: { only: "street" } }) end + def test_multiple_includes_with_options + expected = { "email" => "david@example.com", "gender" => "male", "name" => "David", + "address" => { "street" => "123 Lane" } } + assert_equal expected, @user.serializable_hash(include: { address: { only: "street" } }) + end + def test_nested_include @user.friends.first.friends = [@user] expected = { "email" => "david@example.com", "gender" => "male", "name" => "David", @@ -168,8 +174,8 @@ class SerializationTest < ActiveModel::TestCase def test_multiple_includes_with_options expected = { "email" => "david@example.com", "gender" => "male", "name" => "David", "address" => { "street" => "123 Lane" }, - "friends" => [{ "name" => "Joe", "email" => "joe@example.com", "gender" => "male" }, - { "name" => "Sue", "email" => "sue@example.com", "gender" => "female" }] } - assert_equal expected, @user.serializable_hash(include: [{ address: { only: "street" } }, :friends]) + "friends" => [{ "name" => "Joe" }, + { "name" => "Sue" }] } + assert_equal expected, @user.serializable_hash(include: [ address: { only: "street" } , friends: {only: "name"}]) end end |