converted has many to use string key for association, makeing it compatable with has_one; fixed tests that relied on symbol keys for has_many associations

This commit is contained in:
Kevin Bullaughey
2014-09-21 07:52:17 -04:00
parent 34d684ee9a
commit edfd38bdee
5 changed files with 25 additions and 26 deletions

View File

@@ -140,7 +140,7 @@ module ActiveModel
{ id: c.object_id, type: model_name(c) }
end,
},
attachments: [
'attachments' => [
{ type: :image, image: { url: 'U1' }},
{ type: :video, video: { html: 'H1' }}
]
@@ -153,7 +153,7 @@ module ActiveModel
assert_equal({
'mail' => { body: 'Body 1' },
attachments: [
'attachments' => [
{ type: :image, image: { url: 'U1' }},
{ type: :video, video: { html: 'H1' }}
]
@@ -178,7 +178,7 @@ module ActiveModel
{ id: c.object_id, type: model_name(c) }
end
},
attachments: [
'attachments' => [
{ type: :image, image: { fake: 'fake' }},
{ type: :video, video: { fake: 'fake' }}
]

View File

@@ -111,7 +111,7 @@ module ActiveModel
assert_equal({
'post' => { title: 'Title 1', body: 'Body 1', 'comment_ids' => @post.comments.map { |c| c.object_id } },
comments: [{ content: 'C1' }, { content: 'C2' }]
'comments' => [{ content: 'C1' }, { content: 'C2' }]
}, @post_serializer.as_json)
end
@@ -128,7 +128,7 @@ module ActiveModel
name: 'Name 1',
posts: [{ title: 'Title 1', body: 'Body 1', 'comment_ids' => @post.comments.map { |c| c.object_id } }]
},
comments: [{ content: 'C1' }, { content: 'C2' }]
"comments" => [{ content: 'C1' }, { content: 'C2' }]
}, category_serializer.as_json)
end
@@ -138,7 +138,7 @@ module ActiveModel
assert_equal({
'post' => { title: 'Title 1', body: 'Body 1' },
comments: [{ content: 'C1' }, { content: 'C2' }]
'comments' => [{ content: 'C1' }, { content: 'C2' }]
}, @post_serializer.as_json)
end
@@ -155,7 +155,7 @@ module ActiveModel
assert_equal({
'post' => { title: 'Title 1', body: 'Body 1', 'comment_ids' => @post.comments.map { |c| c.object_id } },
comments: [{ content: 'C1!' }, { content: 'C2!' }]
'comments' => [{ content: 'C1!' }, { content: 'C2!' }]
}, @post_serializer.as_json)
end
@@ -170,7 +170,7 @@ module ActiveModel
assert_equal({
'post' => { title: 'Title 1', body: 'Body 1', 'comment_ids' => @post.comments.map { |c| c.object_id } },
comments: { my_content: ['fake'] }
'comments' => { my_content: ['fake'] }
}, @post_serializer.as_json)
end
@@ -191,16 +191,16 @@ module ActiveModel
@association.embed_in_root_key = :linked
@association.embed = :ids
assert_equal({
'post' => {
title: 'Title 1', body: 'Body 1',
'comment_ids' => @post.comments.map(&:object_id)
},
linked: {
comments: [
'comments' => [
{ content: 'C1' },
{ content: 'C2' }
]
},
'post' => {
title: 'Title 1', body: 'Body 1',
'comment_ids' => @post.comments.map(&:object_id)
}
}, @post_serializer.as_json)
end
@@ -211,18 +211,18 @@ module ActiveModel
@association.embed_namespace = :links
@association.key = :comments
assert_equal({
linked: {
comments: [
{ content: 'C1' },
{ content: 'C2' }
]
},
'post' => {
title: 'Title 1', body: 'Body 1',
links: {
comments: @post.comments.map(&:object_id)
}
}
},
linked: {
'comments' => [
{ content: 'C1' },
{ content: 'C2' }
]
},
}, @post_serializer.as_json)
end