mirror of
https://github.com/ditkrg/active_model_serializers.git
synced 2026-01-25 07:16:49 +00:00
has_one returns arrays with roots pluralized
This commit is contained in:
@@ -17,7 +17,7 @@ module ActiveModel
|
||||
ar_comments: [{ body: 'what a dumb post', ar_tags: [{ name: 'short' }, { name: 'whiny' }] },
|
||||
{ body: 'i liked it', ar_tags: [{:name=>"short"}, {:name=>"happy"}] }],
|
||||
ar_tags: [{ name: 'short' }, { name: 'whiny' }, { name: 'happy' }],
|
||||
ar_section: { 'name' => 'ruby' }
|
||||
'ar_sections' => [{ 'name' => 'ruby' }]
|
||||
}
|
||||
}, post_serializer.as_json)
|
||||
end
|
||||
@@ -51,7 +51,7 @@ module ActiveModel
|
||||
ar_comments: [{ body: 'what a dumb post', ar_tags: [{ name: 'short' }, { name: 'whiny' }] },
|
||||
{ body: 'i liked it', ar_tags: [{:name=>"short"}, {:name=>"happy"}] }],
|
||||
ar_tags: [{ name: 'short' }, { name: 'whiny' }, { name: 'happy' }],
|
||||
ar_section: { 'name' => 'ruby' }
|
||||
'ar_sections' => [{ 'name' => 'ruby' }]
|
||||
}, post_serializer.as_json)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -50,7 +50,7 @@ module ActiveModel
|
||||
@association.embed = :objects
|
||||
|
||||
assert_equal({
|
||||
name: 'Name 1', email: 'mail@server.com', profile: { name: 'N1', description: 'D1' }
|
||||
name: 'Name 1', email: 'mail@server.com', 'profiles' => [{ name: 'N1', description: 'D1' }]
|
||||
}, @user_serializer.serializable_hash)
|
||||
end
|
||||
|
||||
@@ -58,7 +58,7 @@ module ActiveModel
|
||||
@association.embed = :objects
|
||||
|
||||
assert_equal({
|
||||
'user' => { name: 'Name 1', email: 'mail@server.com', profile: { name: 'N1', description: 'D1' } }
|
||||
'user' => { name: 'Name 1', email: 'mail@server.com', 'profiles' => [{ name: 'N1', description: 'D1' }] }
|
||||
}, @user_serializer.as_json)
|
||||
end
|
||||
|
||||
@@ -84,7 +84,7 @@ module ActiveModel
|
||||
end
|
||||
|
||||
assert_equal({
|
||||
'user' => { name: 'Name 1', email: 'mail@server.com', profile: nil }
|
||||
'user' => { name: 'Name 1', email: 'mail@server.com', 'profiles' => [] }
|
||||
}, @user_serializer.as_json)
|
||||
end
|
||||
|
||||
@@ -93,7 +93,7 @@ module ActiveModel
|
||||
@association.embedded_key = 'root'
|
||||
|
||||
assert_equal({
|
||||
name: 'Name 1', email: 'mail@server.com', 'root' => { name: 'N1', description: 'D1' }
|
||||
name: 'Name 1', email: 'mail@server.com', 'root' => [{ name: 'N1', description: 'D1' }]
|
||||
}, @user_serializer.serializable_hash)
|
||||
end
|
||||
|
||||
@@ -112,7 +112,7 @@ module ActiveModel
|
||||
|
||||
assert_equal({
|
||||
'user' => { name: 'Name 1', email: 'mail@server.com', 'profile_id' => @user.profile.object_id },
|
||||
profile: { name: 'N1', description: 'D1' }
|
||||
'profiles' => [{ name: 'N1', description: 'D1' }]
|
||||
}, @user_serializer.as_json)
|
||||
end
|
||||
|
||||
@@ -129,7 +129,7 @@ module ActiveModel
|
||||
|
||||
assert_equal({
|
||||
'user' => { name: 'Name 1', email: 'mail@server.com', 'profile_id' => @user.profile.object_id },
|
||||
profile: { name: 'fake' }
|
||||
'profiles' => [{ name: 'fake' }]
|
||||
}, @user_serializer.as_json)
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user