@@ -451,8 +451,9 @@ def test_flow_link_has_many_self_link_put
451451 } )
452452 end
453453
454- def test_flow_self_formatted_route
454+ def test_flow_self_formatted_route_1
455455 JSONAPI . configuration . route_format = :dasherized_route
456+ JSONAPI . configuration . json_key_format = :dasherized_key
456457 get '/api/v6/purchase-orders'
457458 assert_equal 200 , status
458459 po_1 = json_response [ 'data' ] [ 0 ]
@@ -462,6 +463,18 @@ def test_flow_self_formatted_route
462463 assert_hash_equals po_1 , json_response [ 'data' ]
463464 end
464465
466+ def test_flow_self_formatted_route_2
467+ JSONAPI . configuration . route_format = :underscored_route
468+ JSONAPI . configuration . json_key_format = :dasherized_key
469+ get '/api/v7/purchase_orders'
470+ assert_equal 200 , status
471+ po_1 = json_response [ 'data' ] [ 0 ]
472+
473+ get po_1 [ 'links' ] [ 'self' ]
474+ assert_equal 200 , status
475+ assert_hash_equals po_1 , json_response [ 'data' ]
476+ end
477+
465478 def test_post_formatted_keys
466479 JSONAPI . configuration . route_format = :dasherized_route
467480 JSONAPI . configuration . json_key_format = :dasherized_key
@@ -476,6 +489,34 @@ def test_post_formatted_keys
476489 assert_equal 201 , status
477490 end
478491
492+ def test_post_formatted_keys_different_route_key_1
493+ JSONAPI . configuration . route_format = :dasherized_route
494+ JSONAPI . configuration . json_key_format = :underscored_key
495+ post '/api/v6/purchase-orders' ,
496+ {
497+ 'data' => {
498+ 'delivery_name' => 'ASDFG Corp' ,
499+ 'type' => 'purchase_orders'
500+ }
501+ } . to_json , "CONTENT_TYPE" => JSONAPI ::MEDIA_TYPE
502+
503+ assert_equal 201 , status
504+ end
505+
506+ def test_post_formatted_keys_different_route_key_2
507+ JSONAPI . configuration . route_format = :underscored_route
508+ JSONAPI . configuration . json_key_format = :dasherized_key
509+ post '/api/v7/purchase_orders' ,
510+ {
511+ 'data' => {
512+ 'delivery-name' => 'ASDFG Corp' ,
513+ 'type' => 'purchase-orders'
514+ }
515+ } . to_json , "CONTENT_TYPE" => JSONAPI ::MEDIA_TYPE
516+
517+ assert_equal 201 , status
518+ end
519+
479520 def test_post_formatted_keys_wrong_format
480521 JSONAPI . configuration . route_format = :dasherized_route
481522 JSONAPI . configuration . json_key_format = :dasherized_key
0 commit comments