Skip to content

Commit f4427fd

Browse files
committed
New request tests for dasherized formats
1 parent 6b2083b commit f4427fd

1 file changed

Lines changed: 38 additions & 0 deletions

File tree

test/integration/requests/request_test.rb

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -451,4 +451,42 @@ def test_flow_link_has_many_self_link_put
451451
})
452452
end
453453

454+
def test_flow_self_formatted_route
455+
JSONAPI.configuration.route_format = :dasherized_route
456+
get '/api/v6/purchase-orders'
457+
assert_equal 200, status
458+
po_1 = json_response['data'][0]
459+
460+
get po_1['links']['self']
461+
assert_equal 200, status
462+
assert_hash_equals po_1, json_response['data']
463+
end
464+
465+
def test_post_formatted_keys
466+
JSONAPI.configuration.route_format = :dasherized_route
467+
JSONAPI.configuration.json_key_format = :dasherized_key
468+
post '/api/v6/purchase-orders',
469+
{
470+
'data' => {
471+
'delivery-name' => 'ASDFG Corp',
472+
'type' => 'purchase-orders'
473+
}
474+
}.to_json, "CONTENT_TYPE" => JSONAPI::MEDIA_TYPE
475+
476+
assert_equal 201, status
477+
end
478+
479+
def test_post_formatted_keys_wrong_format
480+
JSONAPI.configuration.route_format = :dasherized_route
481+
JSONAPI.configuration.json_key_format = :dasherized_key
482+
post '/api/v6/purchase-orders',
483+
{
484+
'data' => {
485+
'delivery_name' => 'ASDFG Corp',
486+
'type' => 'purchase-orders'
487+
}
488+
}.to_json, "CONTENT_TYPE" => JSONAPI::MEDIA_TYPE
489+
490+
assert_equal 400, status
491+
end
454492
end

0 commit comments

Comments
 (0)