Skip to content

Commit 4aca6d7

Browse files
committed
add failing test for minimal POST
POST with only 'type' key is not triggering a save on the activerecord model, but no errors are reported. This leads to an incorrect 201 status.
1 parent 4f86a43 commit 4aca6d7

1 file changed

Lines changed: 12 additions & 1 deletion

File tree

test/integration/requests/request_test.rb

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,17 @@ def test_post_single
156156
assert_equal 201, status
157157
end
158158

159+
def test_post_single_minimal_invalid
160+
post '/posts',
161+
{
162+
'data' => {
163+
'type' => 'posts'
164+
}
165+
}.to_json, "CONTENT_TYPE" => JSONAPI::MEDIA_TYPE
166+
167+
assert_equal 422, status
168+
end
169+
159170
def test_update_association_without_content_type
160171
ruby = Section.find_by(name: 'ruby')
161172
patch '/posts/3/links/section', { 'data' => {type: 'sections', id: ruby.id.to_s }}.to_json
@@ -189,7 +200,7 @@ def test_patch_update_association_has_many_acts_as_set
189200
def test_post_update_association_has_many
190201
rogue = Comment.find_by(body: 'Rogue Comment Here')
191202
post '/posts/5/links/comments', { 'data' => [{type: 'comments', id: rogue.id.to_s }]}.to_json, "CONTENT_TYPE" => JSONAPI::MEDIA_TYPE
192-
203+
193204
assert_equal 204, status
194205
end
195206

0 commit comments

Comments
 (0)