Commit b5acb2e3 authored by Toon Claes's avatar Toon Claes

POST instead of DELETE to unapprove an MR through the API

parent d071f965
......@@ -640,6 +640,24 @@ POST /projects/:id/merge_requests/:merge_request_iid/approve
}
```
## Unapprove Merge Request
>**Note:** This API endpoint is only available on 9.0 EE and above.
If you did approve a merge request, you can unapprove it using the following
endpoint:
```
POST /projects/:id/merge_requests/:merge_request_iid/unapprove
```
**Parameters:**
| Attribute | Type | Required | Description |
|---------------------|---------|----------|---------------------|
| `id` | integer | yes | The ID of a project |
| `merge_request_iid` | integer | yes | The IID of MR |
## Cancel Merge When Pipeline Succeeds
If you don't have permissions to accept this merge request - you'll get a `401`
......
......@@ -87,3 +87,4 @@ Below are the changes made between V3 and V4.
- Remove the ProjectGitHook API. Use the ProjectPushRule API instead [!1301](https://gitlab.com/gitlab-org/gitlab-ee/merge_requests/1301)
- Removed `repository_storage` from `PUT /application/settings` and `GET /application/settings` (use `repository_storages` instead) [!1307](https://gitlab.com/gitlab-org/gitlab-ee/merge_requests/1307)
- Removed `elasticsearch_host` and `elasticsearch_port` from `PUT /application/settings` (use `elasticsearch_url` instead) [!1305](https://gitlab.com/gitlab-org/gitlab-ee/merge_requests/1305)
- Make approval API more RESTful. Use `POST /projects/:id/merge_requests/:merge_request_iid/unapprove` to unapprove a merge request. [!1518](https://gitlab.com/gitlab-org/gitlab-ee/merge_requests/1518)
......@@ -279,7 +279,7 @@ module API
present merge_request, with: Entities::MergeRequestApprovals, current_user: current_user
end
delete ':id/merge_requests/:merge_request_iid/unapprove' do
post ':id/merge_requests/:merge_request_iid/unapprove' do
merge_request = find_project_merge_request(params[:merge_request_iid])
not_found! unless merge_request.has_approved?(current_user)
......
......@@ -887,7 +887,7 @@ describe API::MergeRequests, api: true do
end
end
describe 'DELETE :id/merge_requests/:merge_request_iid/unapprove' do
describe 'POST :id/merge_requests/:merge_request_iid/unapprove' do
before { project.update_attribute(:approvals_before_merge, 2) }
context 'as a user who has approved the merge request' do
......@@ -901,11 +901,11 @@ describe API::MergeRequests, api: true do
merge_request.approvals.create(user: approver)
merge_request.approvals.create(user: unapprover)
delete api("/projects/#{project.id}/merge_requests/#{merge_request.iid}/unapprove", unapprover)
post api("/projects/#{project.id}/merge_requests/#{merge_request.iid}/unapprove", unapprover)
end
it 'unapproves the merge request' do
expect(response.status).to eq(200)
expect(response.status).to eq(201)
expect(json_response['approvals_left']).to eq(1)
usernames = json_response['approved_by'].map { |u| u['user']['username'] }
expect(usernames).not_to include(unapprover.username)
......
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