@@ -103,6 +103,13 @@ def test_index_filter_by_title
103103 assert_equal 1 , json_response [ 'data' ] . size
104104 end
105105
106+ def test_index_filter_with_hash_values
107+ get :index , { filter : { search : { title : 'New post' } } }
108+ assert_response :success
109+ assert json_response [ 'data' ] . is_a? ( Array )
110+ assert_equal 1 , json_response [ 'data' ] . size
111+ end
112+
106113 def test_index_filter_by_ids
107114 get :index , params : { filter : { ids : '1,2' } }
108115 assert_response :success
@@ -412,6 +419,7 @@ def test_create_simple
412419 assert json_response [ 'data' ] . is_a? ( Hash )
413420 assert_equal 'JR is Great' , json_response [ 'data' ] [ 'attributes' ] [ 'title' ]
414421 assert_equal 'JSONAPIResources is the greatest thing since unsliced bread.' , json_response [ 'data' ] [ 'attributes' ] [ 'body' ]
422+ assert_equal json_response [ 'data' ] [ 'links' ] [ 'self' ] , response . location
415423 end
416424
417425 def test_create_link_to_missing_object
@@ -433,6 +441,7 @@ def test_create_link_to_missing_object
433441 assert_response :unprocessable_entity
434442 # TODO: check if this validation is working
435443 assert_match /author - can't be blank/ , response . body
444+ assert_equal nil , response . location
436445 end
437446
438447 def test_create_extra_param
@@ -454,6 +463,7 @@ def test_create_extra_param
454463
455464 assert_response :bad_request
456465 assert_match /asdfg is not allowed/ , response . body
466+ assert_equal nil , response . location
457467 end
458468
459469 def test_create_extra_param_allow_extra_params
@@ -486,6 +496,7 @@ def test_create_extra_param_allow_extra_params
486496 assert_equal "Param not allowed" , json_response [ 'meta' ] [ "warnings" ] [ 0 ] [ "title" ]
487497 assert_equal "asdfg is not allowed." , json_response [ 'meta' ] [ "warnings" ] [ 0 ] [ "detail" ]
488498 assert_equal '105' , json_response [ 'meta' ] [ "warnings" ] [ 0 ] [ "code" ]
499+ assert_equal json_response [ 'data' ] [ 'links' ] [ 'self' ] , response . location
489500 ensure
490501 JSONAPI . configuration . raise_if_parameters_not_allowed = true
491502 end
@@ -515,6 +526,7 @@ def test_create_with_invalid_data
515526 assert_equal "/data/attributes/title" , json_response [ 'errors' ] [ 1 ] [ 'source' ] [ 'pointer' ]
516527 assert_equal "is too long (maximum is 35 characters)" , json_response [ 'errors' ] [ 1 ] [ 'title' ]
517528 assert_equal "title - is too long (maximum is 35 characters)" , json_response [ 'errors' ] [ 1 ] [ 'detail' ]
529+ assert_equal nil , response . location
518530 end
519531
520532 def test_create_multiple
@@ -551,6 +563,7 @@ def test_create_multiple
551563 assert_nil json_response [ 'data' ] [ 0 ] [ 'relationships' ] [ 'author' ] [ 'data' ]
552564 assert_match /JR is Great/ , response . body
553565 assert_match /Ember is Great/ , response . body
566+ assert_equal nil , response . location
554567 end
555568
556569 def test_create_multiple_wrong_case
@@ -583,6 +596,7 @@ def test_create_multiple_wrong_case
583596
584597 assert_response :bad_request
585598 assert_match /Title/ , json_response [ 'errors' ] [ 0 ] [ 'detail' ]
599+ assert_equal nil , response . location
586600 end
587601
588602 def test_create_simple_missing_posts
@@ -603,6 +617,7 @@ def test_create_simple_missing_posts
603617
604618 assert_response :bad_request
605619 assert_match /The required parameter, data, is missing./ , json_response [ 'errors' ] [ 0 ] [ 'detail' ]
620+ assert_equal nil , response . location
606621 end
607622
608623 def test_create_simple_wrong_type
@@ -623,6 +638,7 @@ def test_create_simple_wrong_type
623638
624639 assert_response :bad_request
625640 assert_match /posts_spelled_wrong is not a valid resource./ , json_response [ 'errors' ] [ 0 ] [ 'detail' ]
641+ assert_equal nil , response . location
626642 end
627643
628644 def test_create_simple_missing_type
@@ -642,6 +658,7 @@ def test_create_simple_missing_type
642658
643659 assert_response :bad_request
644660 assert_match /The required parameter, type, is missing./ , json_response [ 'errors' ] [ 0 ] [ 'detail' ]
661+ assert_equal nil , response . location
645662 end
646663
647664 def test_create_simple_unpermitted_attributes
@@ -662,6 +679,7 @@ def test_create_simple_unpermitted_attributes
662679
663680 assert_response :bad_request
664681 assert_match /subject/ , json_response [ 'errors' ] [ 0 ] [ 'detail' ]
682+ assert_equal nil , response . location
665683 end
666684
667685 def test_create_simple_unpermitted_attributes_allow_extra_params
@@ -696,6 +714,7 @@ def test_create_simple_unpermitted_attributes_allow_extra_params
696714 assert_equal "Param not allowed" , json_response [ 'meta' ] [ "warnings" ] [ 0 ] [ "title" ]
697715 assert_equal "subject is not allowed." , json_response [ 'meta' ] [ "warnings" ] [ 0 ] [ "detail" ]
698716 assert_equal '105' , json_response [ 'meta' ] [ "warnings" ] [ 0 ] [ "code" ]
717+ assert_equal json_response [ 'data' ] [ 'links' ] [ 'self' ] , response . location
699718 ensure
700719 JSONAPI . configuration . raise_if_parameters_not_allowed = true
701720 end
@@ -723,6 +742,7 @@ def test_create_with_links_to_many_type_ids
723742 assert_equal '3' , json_response [ 'data' ] [ 'relationships' ] [ 'author' ] [ 'data' ] [ 'id' ]
724743 assert_equal 'JR is Great' , json_response [ 'data' ] [ 'attributes' ] [ 'title' ]
725744 assert_equal 'JSONAPIResources is the greatest thing since unsliced bread.' , json_response [ 'data' ] [ 'attributes' ] [ 'body' ]
745+ assert_equal json_response [ 'data' ] [ 'links' ] [ 'self' ] , response . location
726746 end
727747
728748 def test_create_with_links_to_many_array
@@ -748,6 +768,7 @@ def test_create_with_links_to_many_array
748768 assert_equal '3' , json_response [ 'data' ] [ 'relationships' ] [ 'author' ] [ 'data' ] [ 'id' ]
749769 assert_equal 'JR is Great' , json_response [ 'data' ] [ 'attributes' ] [ 'title' ]
750770 assert_equal 'JSONAPIResources is the greatest thing since unsliced bread.' , json_response [ 'data' ] [ 'attributes' ] [ 'body' ]
771+ assert_equal json_response [ 'data' ] [ 'links' ] [ 'self' ] , response . location
751772 end
752773
753774 def test_create_with_links_include_and_fields
@@ -774,6 +795,7 @@ def test_create_with_links_include_and_fields
774795 assert_equal '3' , json_response [ 'data' ] [ 'relationships' ] [ 'author' ] [ 'data' ] [ 'id' ]
775796 assert_equal 'JR is Great!' , json_response [ 'data' ] [ 'attributes' ] [ 'title' ]
776797 assert_not_nil json_response [ 'included' ] . size
798+ assert_equal json_response [ 'data' ] [ 'links' ] [ 'self' ] , response . location
777799 end
778800
779801 def test_update_with_links
0 commit comments