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