Commit 9b91e681 authored by Shinya Maeda's avatar Shinya Maeda

Cancel auto merge when merge request is closed

We should cancel auto merge when merge request is closed.
parent 9a9c947b
...@@ -18,6 +18,7 @@ module MergeRequests ...@@ -18,6 +18,7 @@ module MergeRequests
invalidate_cache_counts(merge_request, users: merge_request.assignees) invalidate_cache_counts(merge_request, users: merge_request.assignees)
merge_request.update_project_counter_caches merge_request.update_project_counter_caches
cleanup_environments(merge_request) cleanup_environments(merge_request)
cancel_auto_merge(merge_request)
end end
merge_request merge_request
...@@ -33,5 +34,9 @@ module MergeRequests ...@@ -33,5 +34,9 @@ module MergeRequests
merge_request_metrics_service(merge_request).close(close_event) merge_request_metrics_service(merge_request).close(close_event)
end end
end end
def cancel_auto_merge(merge_request)
AutoMergeService.new(project, current_user).cancel(merge_request)
end
end end
end end
---
title: Cancel auto merge when merge request is closed
merge_request: 28782
author:
type: fixed
...@@ -52,6 +52,14 @@ describe MergeRequests::CloseService do ...@@ -52,6 +52,14 @@ describe MergeRequests::CloseService do
it 'marks todos as done' do it 'marks todos as done' do
expect(todo.reload).to be_done expect(todo.reload).to be_done
end 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 end
it 'updates metrics' do it 'updates metrics' do
......
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