Skip to content

Commit

Permalink
Edit approvals/approvers fix (#493)
Browse files Browse the repository at this point in the history
* Fix edit_project_approvers

Fix edit_project_approvers to use correct API path & update comments to properly reflect options as required, and to set to nil if you want one or both of them empty.

* Merge request approvals/approvers fix

* Merge request approvals/approvers spec fix
  • Loading branch information
Quantu authored and NARKOZ committed Mar 27, 2019
1 parent c282dd3 commit 040f5f6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
12 changes: 6 additions & 6 deletions lib/gitlab/client/merge_request_approvals.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def project_merge_request_approvals(project)
# @option options [Boolean] :disable_overriding_approvers_per_merge_request(optional) Allow/Disallow overriding approvers per MR
# @return [Gitlab::ObjectifiedHash] MR approval configuration information about the project
def edit_project_merge_request_approvals(project, options = {})
post("/projects/#{url_encode project}/approvers", body: options)
post("/projects/#{url_encode project}/approvals", body: options)
end

# Change allowed approvers and approver groups for a project
Expand All @@ -37,11 +37,11 @@ def edit_project_merge_request_approvals(project, options = {})
# Gitlab.edit_project_approvers(1, {approver_ids: [5], approver_groups: [1]})
#
# @param [Integer] project(required) The ID of a project.
# @option options [Array] :approver_ids(optional) An array of User IDs that can approve MRs
# @option options [Array] :approver_group_ids(optional) An array of Group IDs whose members can approve MRs
# @option options [Array] :approver_ids(required, nil if none) An array of User IDs that can approve MRs
# @option options [Array] :approver_group_ids(required, nil if none) An array of Group IDs whose members can approve MRs
# @return [Gitlab::ObjectifiedHash] MR approval configuration information about the project
def edit_project_approvers(project, options = {})
put("/projects/#{url_encode project}/approvals", body: options)
put("/projects/#{url_encode project}/approvers", body: options)
end

# Get Configuration for approvals on a specific Merge Request.
Expand Down Expand Up @@ -76,8 +76,8 @@ def edit_merge_request_approvals(project, merge_request, options = {})
#
# @param [Integer] project(required) The ID of a project.
# @param [Integer] merge_request(required) The IID of a merge_request.
# @option options [Array] :approver_ids(optional) An array of User IDs that can approve MRs
# @option options [Array] :approver_group_ids(optional) An array of Group IDs whose members can approve MRs
# @option options [Array] :approver_ids(required, nil if none) An array of User IDs that can approve MRs
# @option options [Array] :approver_group_ids(required, nil if none) An array of Group IDs whose members can approve MRs
# @return [Gitlab::ObjectifiedHash] MR approval configuration information about the project
def edit_merge_request_approvers(project, merge_request, options = {})
put("/projects/#{url_encode project}/merge_requests/#{merge_request}/approvers", body: options)
Expand Down
8 changes: 4 additions & 4 deletions spec/gitlab/client/merge_request_approvals_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@
describe '.edit_project_merge_request_approvals' do
before do
body = { approvals_before_merge: '3', reset_approvals_on_push: 'false', disable_overriding_approvers_per_merge_request: 'true' }
stub_post('/projects/1/approvers', 'project_merge_request_approvals').with(body: body)
stub_post('/projects/1/approvals', 'project_merge_request_approvals').with(body: body)
@project_mr_approvals = Gitlab.edit_project_merge_request_approvals(1, approvals_before_merge: 3, reset_approvals_on_push: false, disable_overriding_approvers_per_merge_request: true)
end

it 'gets the correct resource' do
body = { approvals_before_merge: '3', reset_approvals_on_push: 'false', disable_overriding_approvers_per_merge_request: 'true' }
expect(a_post('/projects/1/approvers')
expect(a_post('/projects/1/approvals')
.with(body: body)).to have_been_made
end

Expand All @@ -42,13 +42,13 @@
describe '.edit_project_approvers' do
before do
body = { "approver_ids": ['5'], "approver_group_ids": ['1'] }
stub_put('/projects/1/approvals', 'project_merge_request_approvals').with(body: body)
stub_put('/projects/1/approvers', 'project_merge_request_approvals').with(body: body)
@project_mr_approvals = Gitlab.edit_project_approvers(1, approver_ids: [5], approver_group_ids: [1])
end

it 'gets the correct resource' do
body = { "approver_ids": ['5'], "approver_group_ids": ['1'] }
expect(a_put('/projects/1/approvals')
expect(a_put('/projects/1/approvers')
.with(body: body)).to have_been_made
end

Expand Down

0 comments on commit 040f5f6

Please sign in to comment.