@@ -6,13 +6,13 @@ class JsonApi
6
6
class DeserializationTest < ActionController ::TestCase
7
7
class DeserializationTestController < ActionController ::Base
8
8
def render_parsed_payload
9
- parsed_hash = ActiveModelSerializers ::Deserialization . jsonapi_parse ( params )
9
+ parsed_hash = ActiveModelSerializers ::Deserialization . jsonapi_parse ( params [ 'resource' ] )
10
10
render json : parsed_hash
11
11
end
12
12
13
13
def render_polymorphic_parsed_payload
14
14
parsed_hash = ActiveModelSerializers ::Deserialization . jsonapi_parse (
15
- params ,
15
+ params [ 'resource' ] ,
16
16
polymorphic : [ :restriction_for , :restricted_to ]
17
17
)
18
18
render json : parsed_hash
@@ -23,17 +23,19 @@ def render_polymorphic_parsed_payload
23
23
24
24
def test_deserialization_of_relationship_only_object
25
25
hash = {
26
- 'data' => {
27
- 'type' => 'restraints' ,
28
- 'relationships' => {
29
- 'restriction_for' => {
30
- 'data' => {
31
- 'type' => 'discounts' ,
32
- 'id' => '67'
26
+ 'resource' => {
27
+ 'data' => {
28
+ 'type' => 'restraints' ,
29
+ 'relationships' => {
30
+ 'restriction_for' => {
31
+ 'data' => {
32
+ 'type' => 'discounts' ,
33
+ 'id' => '67'
34
+ }
35
+ } ,
36
+ 'restricted_to' => {
37
+ 'data' => nil
33
38
}
34
- } ,
35
- 'restricted_to' => {
36
- 'data' => nil
37
39
}
38
40
}
39
41
} ,
@@ -55,34 +57,36 @@ def test_deserialization_of_relationship_only_object
55
57
56
58
def test_deserialization
57
59
hash = {
58
- 'data' => {
59
- 'type' => 'photos' ,
60
- 'id' => 'zorglub' ,
61
- 'attributes' => {
62
- 'title' => 'Ember Hamster' ,
63
- 'src' => 'http://example.com/images/productivity.png' ,
64
- 'image-width' => '200' ,
65
- 'imageHeight' => '200' ,
66
- 'ImageSize' => '1024'
67
- } ,
68
- 'relationships' => {
69
- 'author' => {
70
- 'data' => nil
71
- } ,
72
- 'photographer' => {
73
- 'data' => { 'type' => 'people' , 'id' => '9' }
60
+ 'resource' => {
61
+ 'data' => {
62
+ 'type' => 'photos' ,
63
+ 'id' => 'zorglub' ,
64
+ 'attributes' => {
65
+ 'title' => 'Ember Hamster' ,
66
+ 'src' => 'http://example.com/images/productivity.png' ,
67
+ 'image-width' => '200' ,
68
+ 'imageHeight' => '200' ,
69
+ 'ImageSize' => '1024'
74
70
} ,
75
- 'comments' => {
76
- 'data' => [
77
- { 'type' => 'comments' , 'id' => '1' } ,
78
- { 'type' => 'comments' , 'id' => '2' }
79
- ]
80
- } ,
81
- 'related-images' => {
82
- 'data' => [
83
- { 'type' => 'image' , 'id' => '7' } ,
84
- { 'type' => 'image' , 'id' => '8' }
85
- ]
71
+ 'relationships' => {
72
+ 'author' => {
73
+ 'data' => nil
74
+ } ,
75
+ 'photographer' => {
76
+ 'data' => { 'type' => 'people' , 'id' => '9' }
77
+ } ,
78
+ 'comments' => {
79
+ 'data' => [
80
+ { 'type' => 'comments' , 'id' => '1' } ,
81
+ { 'type' => 'comments' , 'id' => '2' }
82
+ ]
83
+ } ,
84
+ 'related-images' => {
85
+ 'data' => [
86
+ { 'type' => 'image' , 'id' => '7' } ,
87
+ { 'type' => 'image' , 'id' => '8' }
88
+ ]
89
+ }
86
90
}
87
91
}
88
92
}
0 commit comments