diff options
author | Grzegorz Bizon <grzegorz@gitlab.com> | 2019-06-04 11:24:07 +0000 |
---|---|---|
committer | Grzegorz Bizon <grzegorz@gitlab.com> | 2019-06-04 11:24:07 +0000 |
commit | 5d2595da56f911ad30aaa7d7b2603d8bd640adb8 (patch) | |
tree | 7923283a15f64202db92bdd33b48a3f55fd594e2 | |
parent | 0b864208e44a1ab44754926f1d1529479387b360 (diff) | |
parent | 9b91e6816ce6b7544856fd2b52049836b5e2d250 (diff) | |
download | gitlab-ce-5d2595da56f911ad30aaa7d7b2603d8bd640adb8.tar.gz |
Merge branch 'cancel-auto-merge-when-merge-request-is-closed' into 'master'
Cancel auto merge when merge request is closed
See merge request gitlab-org/gitlab-ce!28782
3 files changed, 18 insertions, 0 deletions
diff --git a/app/services/merge_requests/close_service.rb b/app/services/merge_requests/close_service.rb index e77051bb1c9..b0f6166ea1c 100644 --- a/app/services/merge_requests/close_service.rb +++ b/app/services/merge_requests/close_service.rb @@ -18,6 +18,7 @@ module MergeRequests invalidate_cache_counts(merge_request, users: merge_request.assignees) merge_request.update_project_counter_caches cleanup_environments(merge_request) + cancel_auto_merge(merge_request) end merge_request @@ -33,5 +34,9 @@ module MergeRequests merge_request_metrics_service(merge_request).close(close_event) end end + + def cancel_auto_merge(merge_request) + AutoMergeService.new(project, current_user).cancel(merge_request) + end end end diff --git a/changelogs/unreleased/cancel-auto-merge-when-merge-request-is-closed.yml b/changelogs/unreleased/cancel-auto-merge-when-merge-request-is-closed.yml new file mode 100644 index 00000000000..d38046ebcbf --- /dev/null +++ b/changelogs/unreleased/cancel-auto-merge-when-merge-request-is-closed.yml @@ -0,0 +1,5 @@ +--- +title: Cancel auto merge when merge request is closed +merge_request: 28782 +author: +type: fixed diff --git a/spec/services/merge_requests/close_service_spec.rb b/spec/services/merge_requests/close_service_spec.rb index ffa612cf315..29b7e0f17e2 100644 --- a/spec/services/merge_requests/close_service_spec.rb +++ b/spec/services/merge_requests/close_service_spec.rb @@ -52,6 +52,14 @@ describe MergeRequests::CloseService do it 'marks todos as done' do expect(todo.reload).to be_done end + + context 'when auto merge is enabled' do + let(:merge_request) { create(:merge_request, :merge_when_pipeline_succeeds) } + + it 'cancels the auto merge' do + expect(@merge_request).not_to be_auto_merge_enabled + end + end end it 'updates metrics' do |