Commit a17d0527 authored by Sean McGivern's avatar Sean McGivern

Merge branch 'osw-mark-as-merged-as-first-post-merge-action' into 'master'

Mark MR as merged regardless of errors when closing issues

See merge request gitlab-org/gitlab-ce!20218
parents cf0b459b dba2d6ee
...@@ -6,9 +6,9 @@ module MergeRequests ...@@ -6,9 +6,9 @@ module MergeRequests
# #
class PostMergeService < MergeRequests::BaseService class PostMergeService < MergeRequests::BaseService
def execute(merge_request) def execute(merge_request)
merge_request.mark_as_merged
close_issues(merge_request) close_issues(merge_request)
todo_service.merge_merge_request(merge_request, current_user) todo_service.merge_merge_request(merge_request, current_user)
merge_request.mark_as_merged
create_event(merge_request) create_event(merge_request)
create_note(merge_request) create_note(merge_request)
notification_service.merge_mr(merge_request, current_user) notification_service.merge_mr(merge_request, current_user)
......
---
title: Mark MR as merged regardless of errors when closing issues
merge_request:
author:
type: fixed
...@@ -47,5 +47,18 @@ describe MergeRequests::PostMergeService do ...@@ -47,5 +47,18 @@ describe MergeRequests::PostMergeService do
expect(diff_removal_service).to have_received(:execute) expect(diff_removal_service).to have_received(:execute)
end end
it 'marks MR as merged regardless of errors when closing issues' do
merge_request.update(target_branch: 'foo')
allow(project).to receive(:default_branch).and_return('foo')
issue = create(:issue, project: project)
allow(merge_request).to receive(:closes_issues).and_return([issue])
allow_any_instance_of(Issues::CloseService).to receive(:execute).with(issue, commit: merge_request).and_raise
expect { described_class.new(project, user, {}).execute(merge_request) }.to raise_error
expect(merge_request.reload).to be_merged
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