mirror of
https://github.com/ditkrg/active_model_serializers.git
synced 2026-01-25 07:16:49 +00:00
Includes links inside of linked resources
According to http://jsonapi.org/format/#document-structure-resource-objects, > Resource objects have the same internal structure, regardless of > whether they represent primary or linked resources. And then http://jsonapi.org/format/#document-structure-resource-object-attributes, > There are four reserved keys in resource objects: > > "id" > "type" > "href" > "links" This commits includes `links` inside of linked resources.
This commit is contained in:
@@ -32,7 +32,16 @@ module ActiveModel
|
||||
|
||||
def test_includes_linked_post
|
||||
@adapter = ActiveModel::Serializer::Adapter::JsonApi.new(@serializer, include: 'post')
|
||||
assert_equal([{id: "42", title: 'New Post', body: 'Body'}], @adapter.serializable_hash[:linked][:posts])
|
||||
expected = [{
|
||||
id: "42",
|
||||
title: 'New Post',
|
||||
body: 'Body',
|
||||
links: {
|
||||
comments: ["1"],
|
||||
author: "1"
|
||||
}
|
||||
}]
|
||||
assert_equal expected, @adapter.serializable_hash[:linked][:posts]
|
||||
end
|
||||
|
||||
def test_include_nil_author
|
||||
|
||||
Reference in New Issue
Block a user