Commit bc57ad04 authored by Robert Speicher's avatar Robert Speicher

Add `error_code` to cherry-pick/revert responses

parent 85fd72fe
...@@ -223,7 +223,7 @@ module API ...@@ -223,7 +223,7 @@ module API
present user_project.repository.commit(result[:result]), present user_project.repository.commit(result[:result]),
with: Entities::Commit with: Entities::Commit
else else
render_api_error!(result[:message], 400) error!(result.slice(:message, :error_code), 400, header)
end end
end end
...@@ -257,7 +257,7 @@ module API ...@@ -257,7 +257,7 @@ module API
present user_project.repository.commit(result[:result]), present user_project.repository.commit(result[:result]),
with: Entities::Commit with: Entities::Commit
else else
render_api_error!(result[:message], 400) error!(result.slice(:message, :error_code), 400, header)
end end
end end
......
...@@ -1376,6 +1376,12 @@ describe API::Commits do ...@@ -1376,6 +1376,12 @@ describe API::Commits do
it_behaves_like '400 response' do it_behaves_like '400 response' do
let(:request) { post api(route, current_user), params: { branch: 'markdown' } } let(:request) { post api(route, current_user), params: { branch: 'markdown' } }
end end
it 'includes an error_code in the response' do
post api(route, current_user), params: { branch: 'markdown' }
expect(json_response['error_code']).to eq 'empty'
end
end end
context 'when ref contains a dot' do context 'when ref contains a dot' do
...@@ -1535,6 +1541,19 @@ describe API::Commits do ...@@ -1535,6 +1541,19 @@ describe API::Commits do
let(:request) { post api(route, current_user) } let(:request) { post api(route, current_user) }
end end
end end
context 'when commit is already reverted in the target branch' do
it 'includes an error_code in the response' do
# First one actually reverts
post api(route, current_user), params: { branch: 'markdown' }
# Second one is redundant and should be empty
post api(route, current_user), params: { branch: 'markdown' }
expect(response).to have_gitlab_http_status(400)
expect(json_response['error_code']).to eq 'empty'
end
end
end end
context 'when authenticated', 'as a developer' do context 'when authenticated', 'as a developer' do
......
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