Commit 5154acdc authored by Mark Chao's avatar Mark Chao

Remove duplicated approval endpoints

See https://gitlab.com/gitlab-org/gitlab-ee/issues/10329
parent 0baed81e
...@@ -30,6 +30,7 @@ module EE ...@@ -30,6 +30,7 @@ module EE
mount ::API::ManagedLicenses mount ::API::ManagedLicenses
mount ::API::ProjectApprovals mount ::API::ProjectApprovals
mount ::API::Vulnerabilities mount ::API::Vulnerabilities
mount ::API::MergeRequestApprovals
version 'v3', using: :path do version 'v3', using: :path do
# Although the following endpoints are kept behind V3 namespace, # Although the following endpoints are kept behind V3 namespace,
......
...@@ -6,12 +6,6 @@ module EE ...@@ -6,12 +6,6 @@ module EE
extend ActiveSupport::Concern extend ActiveSupport::Concern
prepended do prepended do
# For reasons unknown, this API must be mounted before we mount
# API::MergeRequests. Mounting this API later on (using
# EE::API::Endpoints) for example will result in various merge request
# approval related tests failing.
::API::API.mount(::API::MergeRequestApprovals)
helpers do helpers do
params :optional_params_ee do params :optional_params_ee do
optional :approvals_before_merge, type: Integer, desc: 'Number of approvals required before this can be merged' optional :approvals_before_merge, type: Integer, desc: 'Number of approvals required before this can be merged'
...@@ -26,71 +20,6 @@ module EE ...@@ -26,71 +20,6 @@ module EE
desc: 'Return merge requests which have specified the users with the given IDs as an individual approver' desc: 'Return merge requests which have specified the users with the given IDs as an individual approver'
end end
end end
params do
requires :id, type: String, desc: 'The ID of a project'
end
resource :projects, requirements: ::API::API::NAMESPACE_OR_PROJECT_REQUIREMENTS do
# Get the status of the merge request's approvals
#
# Parameters:
# id (required) - The ID of a project
# merge_request_idd (required) - IID of MR
# Examples:
# GET /projects/:id/merge_requests/:merge_request_iid/approvals
#
desc "List a merge request's approvals" do
success EE::API::Entities::MergeRequestApprovals
end
get ':id/merge_requests/:merge_request_iid/approvals' do
merge_request = find_merge_request_with_access(params[:merge_request_iid])
present merge_request, with: EE::API::Entities::MergeRequestApprovals, current_user: current_user
end
# Approve a merge request
#
# Parameters:
# id (required) - The ID of a project
# merge_request_iid (required) - IID of MR
# Examples:
# POST /projects/:id/merge_requests/:merge_request_iid/approve
#
desc 'Approve a merge request' do
success EE::API::Entities::MergeRequestApprovals
end
params do
optional :sha, type: String, desc: 'When present, must have the HEAD SHA of the source branch'
end
post ':id/merge_requests/:merge_request_iid/approve' do
merge_request = find_project_merge_request(params[:merge_request_iid])
unauthorized! unless merge_request.can_approve?(current_user)
check_sha_param!(params, merge_request)
::MergeRequests::ApprovalService
.new(user_project, current_user)
.execute(merge_request)
present merge_request, with: EE::API::Entities::MergeRequestApprovals, current_user: current_user
end
desc 'Remove an approval from a merge request' do
success EE::API::Entities::MergeRequestApprovals
end
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)
::MergeRequests::RemoveApprovalService
.new(user_project, current_user)
.execute(merge_request)
present merge_request, with: EE::API::Entities::MergeRequestApprovals, current_user: current_user
end
end
end end
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