Commit dbd91a93 authored by Patricio Cano's avatar Patricio Cano

Fixed documentation, corrected syntax, and added test scenario for Approvals API

parent 1955f4a1
...@@ -498,8 +498,10 @@ GET /projects/:id/merge_requests/:merge_request_id/approvals ...@@ -498,8 +498,10 @@ GET /projects/:id/merge_requests/:merge_request_id/approvals
**Parameters:** **Parameters:**
- id (required) - The ID of a project | Attribute | Type | Required | Description |
- merge_request_id (required) - ID of MR |--------------------|---------|----------|---------------------|
| `id` | integer | yes | The ID of a project |
| `merge_request_id` | integer | yes | The ID of MR |
```json ```json
{ {
...@@ -542,8 +544,10 @@ POST /projects/:id/merge_requests/:merge_request_id/approvals ...@@ -542,8 +544,10 @@ POST /projects/:id/merge_requests/:merge_request_id/approvals
**Parameters:** **Parameters:**
- id (required) - The ID of a project | Attribute | Type | Required | Description |
- merge_request_id (required) - ID of MR |--------------------|---------|----------|---------------------|
| `id` | integer | yes | The ID of a project |
| `merge_request_id` | integer | yes | The ID of MR |
```json ```json
{ {
......
...@@ -222,12 +222,8 @@ module API ...@@ -222,12 +222,8 @@ module API
class MergeRequestApprovals < ProjectEntity class MergeRequestApprovals < ProjectEntity
expose :merge_status expose :merge_status
expose :approvals_required do |merge_request, _| expose :approvals_required
merge_request.approvals_required expose :approvals_left
end
expose :approvals_missing do |merge_request, _|
merge_request.approvals_left
end
expose :approvals, as: :approved_by, using: Entities::Approvals expose :approvals, as: :approved_by, using: Entities::Approvals
end end
......
...@@ -334,9 +334,10 @@ module API ...@@ -334,9 +334,10 @@ module API
end end
# Get the status of the merge request's approvals # Get the status of the merge request's approvals
#
# Parameters: # Parameters:
# id (required) - The ID of a project # id (required) - The ID of a project
# merge_request_id (required) - ID of MR # merge_request_id (required) - ID of MR
# Examples: # Examples:
# GET /projects/:id/merge_requests/:merge_request_id/approvals # GET /projects/:id/merge_requests/:merge_request_id/approvals
# #
...@@ -348,9 +349,10 @@ module API ...@@ -348,9 +349,10 @@ module API
end end
# Approve a merge request # Approve a merge request
#
# Parameters: # Parameters:
# id (required) - The ID of a project # id (required) - The ID of a project
# merge_request_id (required) - ID of MR # merge_request_id (required) - ID of MR
# Examples: # Examples:
# POST /projects/:id/merge_requests/:merge_request_id/approvals # POST /projects/:id/merge_requests/:merge_request_id/approvals
# #
...@@ -359,9 +361,9 @@ module API ...@@ -359,9 +361,9 @@ module API
unauthorized! unless merge_request.can_approve?(current_user) unauthorized! unless merge_request.can_approve?(current_user)
::MergeRequests::ApprovalService. ::MergeRequests::ApprovalService
new(user_project, current_user). .new(user_project, current_user)
execute(merge_request) .execute(merge_request)
present merge_request, with: Entities::MergeRequestApprovals, current_user: current_user present merge_request, with: Entities::MergeRequestApprovals, current_user: current_user
end end
......
...@@ -616,7 +616,8 @@ describe API::API, api: true do ...@@ -616,7 +616,8 @@ describe API::API, api: true do
post api("/projects/#{project.id}/merge_requests/#{merge_request.id}/approve", user) post api("/projects/#{project.id}/merge_requests/#{merge_request.id}/approve", user)
expect(response.status).to eq(201) expect(response.status).to eq(201)
expect(json_response['approvals_required']).to eq 1 expect(json_response['approvals_left']).to eq(1)
expect(json_response['approved_by'][0]['user']['username']).to eq(user.username)
end end
end end
......
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