Skip to content

Commit 777b5a1

Browse files
committed
Merge branch 'master' into nested-serializers
2 parents 5dbd7c7 + 94cee19 commit 777b5a1

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

lib/active_model/serializer/adapter/json.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ class Json < Base
77

88
def serializable_hash(options = nil)
99
options ||= {}
10-
1110
{ root => Attributes.new(serializer, instance_options).serializable_hash(options) }
1211
end
1312

test/adapter/json/collection_test.rb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,16 @@ def test_root_is_underscored
7575

7676
assert_equal 1, adapter.serializable_hash[:virtual_values].length
7777
end
78+
79+
def test_include_option
80+
serializer = ArraySerializer.new([@first_post, @second_post])
81+
adapter = ActiveModel::Serializer::Adapter::Json.new(serializer, include: '')
82+
actual = adapter.serializable_hash
83+
expected = { posts: [{ id: 1, title: 'Hello!!', body: 'Hello, world!!' },
84+
{ id: 2, title: 'New Post', body: 'Body' }] }
85+
86+
assert_equal(expected, actual)
87+
end
7888
end
7989
end
8090
end

0 commit comments

Comments
 (0)