@@ -32,9 +32,9 @@ def setup
32
32
end
33
33
34
34
def test_includes_post_id
35
- expected = { linkage : { type : "posts" , id : "42" } }
35
+ expected = { data : { type : "posts" , id : "42" } }
36
36
37
- assert_equal ( expected , @adapter . serializable_hash [ :data ] [ :links ] [ :post ] )
37
+ assert_equal ( expected , @adapter . serializable_hash [ :data ] [ :relationships ] [ :post ] )
38
38
end
39
39
40
40
def test_includes_linked_post
@@ -46,10 +46,10 @@ def test_includes_linked_post
46
46
title : 'New Post' ,
47
47
body : 'Body' ,
48
48
} ,
49
- links : {
50
- comments : { linkage : [ { type : "comments" , id : "1" } ] } ,
51
- blog : { linkage : { type : "blogs" , id : "999" } } ,
52
- author : { linkage : { type : "authors" , id : "1" } }
49
+ relationships : {
50
+ comments : { data : [ { type : "comments" , id : "1" } ] } ,
51
+ blog : { data : { type : "blogs" , id : "999" } } ,
52
+ author : { data : { type : "authors" , id : "1" } }
53
53
}
54
54
} ]
55
55
assert_equal expected , @adapter . serializable_hash [ :included ]
@@ -63,10 +63,10 @@ def test_limiting_linked_post_fields
63
63
attributes : {
64
64
title : 'New Post'
65
65
} ,
66
- links : {
67
- comments : { linkage : [ { type : "comments" , id : "1" } ] } ,
68
- blog : { linkage : { type : "blogs" , id : "999" } } ,
69
- author : { linkage : { type : "authors" , id : "1" } }
66
+ relationships : {
67
+ comments : { data : [ { type : "comments" , id : "1" } ] } ,
68
+ blog : { data : { type : "blogs" , id : "999" } } ,
69
+ author : { data : { type : "authors" , id : "1" } }
70
70
}
71
71
} ]
72
72
assert_equal expected , @adapter . serializable_hash [ :included ]
@@ -76,22 +76,22 @@ def test_include_nil_author
76
76
serializer = PostSerializer . new ( @anonymous_post )
77
77
adapter = ActiveModel ::Serializer ::Adapter ::JsonApi . new ( serializer )
78
78
79
- assert_equal ( { comments : { linkage : [ ] } , blog : { linkage : { type : "blogs" , id : "999" } } , author : { linkage : nil } } , adapter . serializable_hash [ :data ] [ :links ] )
79
+ assert_equal ( { comments : { data : [ ] } , blog : { data : { type : "blogs" , id : "999" } } , author : { data : nil } } , adapter . serializable_hash [ :data ] [ :relationships ] )
80
80
end
81
81
82
82
def test_include_type_for_association_when_different_than_name
83
83
serializer = BlogSerializer . new ( @blog )
84
84
adapter = ActiveModel ::Serializer ::Adapter ::JsonApi . new ( serializer )
85
- links = adapter . serializable_hash [ :data ] [ :links ]
85
+ relationships = adapter . serializable_hash [ :data ] [ :relationships ]
86
86
expected = {
87
87
writer : {
88
- linkage : {
88
+ data : {
89
89
type : "authors" ,
90
90
id : "1"
91
91
}
92
92
} ,
93
93
articles : {
94
- linkage : [
94
+ data : [
95
95
{
96
96
type : "posts" ,
97
97
id : "42"
@@ -103,7 +103,7 @@ def test_include_type_for_association_when_different_than_name
103
103
]
104
104
}
105
105
}
106
- assert_equal expected , links
106
+ assert_equal expected , relationships
107
107
end
108
108
109
109
def test_include_linked_resources_with_type_name
@@ -117,10 +117,10 @@ def test_include_linked_resources_with_type_name
117
117
attributes : {
118
118
name : "Steve K."
119
119
} ,
120
- links : {
121
- posts : { linkage : [ ] } ,
122
- roles : { linkage : [ ] } ,
123
- bio : { linkage : nil }
120
+ relationships : {
121
+ posts : { data : [ ] } ,
122
+ roles : { data : [ ] } ,
123
+ bio : { data : nil }
124
124
}
125
125
} , {
126
126
id : "42" ,
@@ -129,10 +129,10 @@ def test_include_linked_resources_with_type_name
129
129
title : "New Post" ,
130
130
body : "Body"
131
131
} ,
132
- links : {
133
- comments : { linkage : [ { type : "comments" , id : "1" } ] } ,
134
- blog : { linkage : { type : "blogs" , id : "999" } } ,
135
- author : { linkage : { type : "authors" , id : "1" } }
132
+ relationships : {
133
+ comments : { data : [ { type : "comments" , id : "1" } ] } ,
134
+ blog : { data : { type : "blogs" , id : "999" } } ,
135
+ author : { data : { type : "authors" , id : "1" } }
136
136
}
137
137
} , {
138
138
id : "43" ,
@@ -141,10 +141,10 @@ def test_include_linked_resources_with_type_name
141
141
title : "Hello!!" ,
142
142
body : "Hello, world!!"
143
143
} ,
144
- links : {
145
- comments : { linkage : [ ] } ,
146
- blog : { linkage : { type : "blogs" , id : "999" } } ,
147
- author : { linkage : nil }
144
+ relationships : {
145
+ comments : { data : [ ] } ,
146
+ blog : { data : { type : "blogs" , id : "999" } } ,
147
+ author : { data : nil }
148
148
}
149
149
}
150
150
]
0 commit comments