@@ -156,6 +156,41 @@ def test_post_single
156156 assert_equal 201 , status
157157 end
158158
159+ def test_post_single_missing_data_contents
160+ post '/posts' ,
161+ {
162+ 'data' => {
163+ }
164+ } . to_json , "CONTENT_TYPE" => JSONAPI ::MEDIA_TYPE
165+
166+ assert_equal 400 , status
167+ end
168+
169+ def test_post_single_minimal_valid
170+ post '/comments' ,
171+ {
172+ 'data' => {
173+ 'type' => 'comments'
174+ }
175+ } . to_json , "CONTENT_TYPE" => JSONAPI ::MEDIA_TYPE
176+
177+ assert_equal 201 , status
178+ assert_nil json_response [ 'data' ] [ 'body' ]
179+ assert_nil json_response [ 'data' ] [ 'links' ] [ 'post' ] [ 'linkage' ]
180+ assert_nil json_response [ 'data' ] [ 'links' ] [ 'author' ] [ 'linkage' ]
181+ end
182+
183+ def test_post_single_minimal_invalid
184+ post '/posts' ,
185+ {
186+ 'data' => {
187+ 'type' => 'posts'
188+ }
189+ } . to_json , "CONTENT_TYPE" => JSONAPI ::MEDIA_TYPE
190+
191+ assert_equal 422 , status
192+ end
193+
159194 def test_update_association_without_content_type
160195 ruby = Section . find_by ( name : 'ruby' )
161196 patch '/posts/3/links/section' , { 'data' => { type : 'sections' , id : ruby . id . to_s } } . to_json
@@ -189,7 +224,7 @@ def test_patch_update_association_has_many_acts_as_set
189224 def test_post_update_association_has_many
190225 rogue = Comment . find_by ( body : 'Rogue Comment Here' )
191226 post '/posts/5/links/comments' , { 'data' => [ { type : 'comments' , id : rogue . id . to_s } ] } . to_json , "CONTENT_TYPE" => JSONAPI ::MEDIA_TYPE
192-
227+
193228 assert_equal 204 , status
194229 end
195230
0 commit comments