has_one returns arrays with roots pluralized

This commit is contained in:
Santiago Pastorino
2013-10-30 15:17:26 -02:00
parent 1eea008336
commit 4d4b820cbe
4 changed files with 20 additions and 14 deletions

View File

@@ -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

View File

@@ -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