mirror of
https://github.com/ditkrg/active_model_serializers.git
synced 2026-01-25 07:16:49 +00:00
Use serializer name as root when root not set
This commit is contained in:
@@ -21,7 +21,7 @@ module ActiveModel
|
||||
|
||||
def test_attributes_serialization_using_as_json
|
||||
assert_equal({
|
||||
'name' => 'Name 1', 'description' => 'Description 1'
|
||||
'profile' => { 'name' => 'Name 1', 'description' => 'Description 1' }
|
||||
}, @profile_serializer.as_json)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -29,7 +29,7 @@ module ActiveModel
|
||||
|
||||
def test_associations_embedding_ids_serialization_using_as_json
|
||||
assert_equal({
|
||||
'title' => 'Title 1', 'body' => 'Body 1', 'comment_ids' => @post.comments.map { |c| c.object_id }
|
||||
'post' => { 'title' => 'Title 1', 'body' => 'Body 1', 'comment_ids' => @post.comments.map { |c| c.object_id } }
|
||||
}, @post_serializer.as_json)
|
||||
end
|
||||
|
||||
@@ -50,7 +50,7 @@ module ActiveModel
|
||||
def test_associations_embedding_objects_serialization_using_as_json
|
||||
@association.embed = :objects
|
||||
assert_equal({
|
||||
'title' => 'Title 1', 'body' => 'Body 1', 'comments' => [{ 'content' => 'C1' }, { 'content' => 'C2' }]
|
||||
'post' => { 'title' => 'Title 1', 'body' => 'Body 1', 'comments' => [{ 'content' => 'C1' }, { 'content' => 'C2' }] }
|
||||
}, @post_serializer.as_json)
|
||||
end
|
||||
|
||||
@@ -63,7 +63,7 @@ module ActiveModel
|
||||
end
|
||||
|
||||
assert_equal({
|
||||
'title' => 'Title 1', 'body' => 'Body 1', 'comments' => [nil]
|
||||
'post' => { 'title' => 'Title 1', 'body' => 'Body 1', 'comments' => [nil] }
|
||||
}, @post_serializer.as_json)
|
||||
end
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ module ActiveModel
|
||||
|
||||
def test_associations_embedding_ids_serialization_using_as_json
|
||||
assert_equal({
|
||||
'name' => 'Name 1', 'email' => 'mail@server.com', 'profile_id' => @user.profile.object_id
|
||||
'user' => { 'name' => 'Name 1', 'email' => 'mail@server.com', 'profile_id' => @user.profile.object_id }
|
||||
}, @user_serializer.as_json)
|
||||
end
|
||||
|
||||
@@ -50,7 +50,7 @@ module ActiveModel
|
||||
def test_associations_embedding_objects_serialization_using_as_json
|
||||
@association.embed = :objects
|
||||
assert_equal({
|
||||
'name' => 'Name 1', 'email' => 'mail@server.com', 'profiles' => [{ 'name' => 'N1', 'description' => 'D1' }]
|
||||
'user' => { 'name' => 'Name 1', 'email' => 'mail@server.com', 'profiles' => [{ 'name' => 'N1', 'description' => 'D1' }] }
|
||||
}, @user_serializer.as_json)
|
||||
end
|
||||
|
||||
@@ -63,7 +63,7 @@ module ActiveModel
|
||||
end
|
||||
|
||||
assert_equal({
|
||||
'name' => 'Name 1', 'email' => 'mail@server.com', 'profiles' => [nil]
|
||||
'user' => { 'name' => 'Name 1', 'email' => 'mail@server.com', 'profiles' => [nil] }
|
||||
}, @user_serializer.as_json)
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user