Commit 32376b4d authored by Heinrich Lee Yu's avatar Heinrich Lee Yu

Merge branch 'http-status-422' into 'master'

Add status 422 in case of errors only

Closes #28505

See merge request gitlab-org/gitlab!19276
parents f8b7f646 c820a44b
......@@ -63,7 +63,11 @@ module NotesActions
json.merge!(note_json(@note))
end
render json: json
if @note.errors.present? && @note.errors.keys != [:commands_only]
render json: json, status: :unprocessable_entity
else
render json: json
end
end
format.html { redirect_back_or_default }
end
......
---
title: Return 422 status code in case of error in submitting comments
merge_request: 19276
author: raju249
type: added
......@@ -259,6 +259,17 @@ describe Projects::NotesController do
end
end
context 'the note does not have commands_only errors' do
context 'for empty note' do
let(:note_text) { '' }
let(:extra_request_params) { { format: :json } }
it "returns status 422 for json" do
expect(response).to have_gitlab_http_status(422)
end
end
end
context 'the project is a private project' do
let(:project_visibility) { Gitlab::VisibilityLevel::PRIVATE }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment