Skip to content

Commit c7b33e4

Browse files
committed
Cleanup tests
Fixes minor issues with tests
1 parent a17f3ab commit c7b33e4

1 file changed

Lines changed: 37 additions & 37 deletions

File tree

test/integration/requests/request_test.rb

Lines changed: 37 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -101,23 +101,23 @@ def test_get_camelized_route_and_links
101101

102102
def test_put_single_without_content_type
103103
put '/posts/3', params:
104-
{
105-
'data' => {
106-
'linkage' => {
107-
'type' => 'posts',
108-
'id' => '3',
109-
},
110-
'attributes' => {
111-
'title' => 'A great new Post'
112-
},
113-
'links' => {
114-
'tags' => [
115-
{type: 'tags', id: 3},
116-
{type: 'tags', id: 4}
104+
{
105+
'data' => {
106+
'type' => 'posts',
107+
'id' => '3',
108+
'attributes' => {
109+
'title' => 'A great new Post'
110+
},
111+
'relationships' => {
112+
'tags' => {
113+
'data' => [
114+
{'type' => 'tags', 'id' => '3'},
115+
{'type' => 'tags', 'id' => '4'}
117116
]
118117
}
119118
}
120-
}.to_json, headers: {"CONTENT_TYPE" => "application/json"}
119+
}
120+
}.to_json
121121

122122
assert_equal 415, status
123123
end
@@ -134,8 +134,8 @@ def test_put_single
134134
'relationships' => {
135135
'tags' => {
136136
'data' => [
137-
{type: 'tags', id: 3},
138-
{type: 'tags', id: 4}
137+
{'type' => 'tags', 'id' => '3'},
138+
{'type' => 'tags', 'id' => '4'}
139139
]
140140
}
141141
}
@@ -148,7 +148,7 @@ def test_put_single
148148
assert_jsonapi_response 200
149149
end
150150

151-
def test_post_single_without_content_type
151+
def test_post_single_with_wrong_content_type
152152
post '/posts', params:
153153
{
154154
'posts' => {
@@ -158,9 +158,9 @@ def test_post_single_without_content_type
158158
'relationships' => {
159159
'tags' => {
160160
'data' => [
161-
{type: 'tags', id: 3},
162-
{type: 'tags', id: 4}
163-
]
161+
{'type' => 'tags', 'id' => '3'},
162+
{'type' => 'tags', 'id' => '4'}
163+
]
164164
}
165165
}
166166
}
@@ -179,7 +179,7 @@ def test_post_single
179179
'body' => 'JSONAPIResources is the greatest thing since unsliced bread.'
180180
},
181181
'relationships' => {
182-
'author' => {'data' => {type: 'people', id: '3'}}
182+
'author' => {'data' => {'type' => 'people', 'id' => '3'}}
183183
}
184184
}
185185
}.to_json,
@@ -236,15 +236,15 @@ def test_post_single_minimal_invalid
236236

237237
def test_update_relationship_without_content_type
238238
ruby = Section.find_by(name: 'ruby')
239-
patch '/posts/3/relationships/section', params: { 'data' => {type: 'sections', id: ruby.id.to_s }}.to_json
239+
patch '/posts/3/relationships/section', params: { 'data' => {'type' => 'sections', 'id' => ruby.id.to_s }}.to_json
240240

241241
assert_equal 415, status
242242
end
243243

244244
def test_patch_update_relationship_to_one
245245
ruby = Section.find_by(name: 'ruby')
246246
patch '/posts/3/relationships/section', params:
247-
{ 'data' => {type: 'sections', id: ruby.id.to_s }}.to_json,
247+
{ 'data' => {'type' => 'sections', 'id' => ruby.id.to_s }}.to_json,
248248
headers: {
249249
"CONTENT_TYPE" => JSONAPI::MEDIA_TYPE
250250
}
@@ -254,7 +254,7 @@ def test_patch_update_relationship_to_one
254254

255255
def test_put_update_relationship_to_one
256256
ruby = Section.find_by(name: 'ruby')
257-
put '/posts/3/relationships/section', params: { 'data' => {type: 'sections', id: ruby.id.to_s }}.to_json,
257+
put '/posts/3/relationships/section', params: { 'data' => {'type' => 'sections', 'id' => ruby.id.to_s }}.to_json,
258258
headers: {
259259
"CONTENT_TYPE" => JSONAPI::MEDIA_TYPE
260260
}
@@ -266,7 +266,7 @@ def test_patch_update_relationship_to_many_acts_as_set
266266
# Comments are acts_as_set=false so PUT/PATCH should respond with 403
267267

268268
rogue = Comment.find_by(body: 'Rogue Comment Here')
269-
patch '/posts/5/relationships/comments', params: { 'data' => [{type: 'comments', id: rogue.id.to_s }]}.to_json,
269+
patch '/posts/5/relationships/comments', params: { 'data' => [{'type' => 'comments', 'id' => rogue.id.to_s }]}.to_json,
270270
headers: {
271271
"CONTENT_TYPE" => JSONAPI::MEDIA_TYPE
272272
}
@@ -276,7 +276,7 @@ def test_patch_update_relationship_to_many_acts_as_set
276276

277277
def test_post_update_relationship_to_many
278278
rogue = Comment.find_by(body: 'Rogue Comment Here')
279-
post '/posts/5/relationships/comments', params: { 'data' => [{type: 'comments', id: rogue.id.to_s }]}.to_json,
279+
post '/posts/5/relationships/comments', params: { 'data' => [{'type' => 'comments', 'id' => rogue.id.to_s }]}.to_json,
280280
headers: {
281281
"CONTENT_TYPE" => JSONAPI::MEDIA_TYPE
282282
}
@@ -288,7 +288,7 @@ def test_put_update_relationship_to_many_acts_as_set
288288
# Comments are acts_as_set=false so PUT/PATCH should respond with 403. Note: JR currently treats PUT and PATCH as equivalent
289289

290290
rogue = Comment.find_by(body: 'Rogue Comment Here')
291-
put '/posts/5/relationships/comments', params: { 'data' => [{type: 'comments', id: rogue.id.to_s }]}.to_json,
291+
put '/posts/5/relationships/comments', params: { 'data' => [{'type' => 'comments', 'id' => rogue.id.to_s }]}.to_json,
292292
headers: {
293293
"CONTENT_TYPE" => JSONAPI::MEDIA_TYPE
294294
}
@@ -318,8 +318,8 @@ def test_put_content_type
318318
'relationships' => {
319319
'tags' => {
320320
'data' => [
321-
{type: 'tags', id: 3},
322-
{type: 'tags', id: 4}
321+
{'type' => 'tags', 'id' => '3'},
322+
{'type' => 'tags', 'id' => '4'}
323323
]
324324
}
325325
}
@@ -344,8 +344,8 @@ def test_patch_content_type
344344
'relationships' => {
345345
'tags' => {
346346
'data' => [
347-
{type: 'tags', id: 3},
348-
{type: 'tags', id: 4}
347+
{'type' => 'tags', 'id' => '3'},
348+
{'type' => 'tags', 'id' => '4'}
349349
]
350350
}
351351
}
@@ -367,7 +367,7 @@ def test_post_correct_content_type
367367
'title' => 'A great new Post'
368368
},
369369
'relationships' => {
370-
'author' => {'data' => {type: 'people', id: '3'}}
370+
'author' => {'data' => {'type' => 'people', 'id' => '3'}}
371371
}
372372
}
373373
}.to_json,
@@ -567,7 +567,7 @@ def test_flow_link_to_one_self_link
567567
'self' => 'http://www.example.com/posts/1/relationships/author',
568568
'related' => 'http://www.example.com/posts/1/author'
569569
},
570-
'data' => {type: 'people', id: '1'}
570+
'data' => {'type' => 'people', 'id' => '1'}
571571
})
572572
end
573573

@@ -585,9 +585,9 @@ def test_flow_link_to_many_self_link
585585
'related' => 'http://www.example.com/posts/1/tags'
586586
},
587587
'data' => [
588-
{type: 'tags', id: '1'},
589-
{type: 'tags', id: '2'},
590-
{type: 'tags', id: '3'}
588+
{'type' => 'tags', 'id' => '1'},
589+
{'type' => 'tags', 'id' => '2'},
590+
{'type' => 'tags', 'id' => '3'}
591591
]
592592
})
593593
end
@@ -614,7 +614,7 @@ def test_flow_link_to_many_self_link_put
614614
'related' => 'http://www.example.com/posts/5/tags'
615615
},
616616
'data' => [
617-
{type: 'tags', id: '10'}
617+
{'type' => 'tags', 'id' => '10'}
618618
]
619619
})
620620
end

0 commit comments

Comments
 (0)