diff options
author | Stan Hu <stanhu@gmail.com> | 2016-07-29 11:14:53 -0700 |
---|---|---|
committer | Stan Hu <stanhu@gmail.com> | 2016-07-29 11:21:21 -0700 |
commit | 60529e021667194c402d4f6e85a83e02a8bb9f75 (patch) | |
tree | ae816493b2f43ec236f274e0edb9ddc46f0366d3 /spec | |
parent | 6ad514d0663bad80e24586be0919a580cdaab8d2 (diff) | |
download | gitlab-ce-60529e021667194c402d4f6e85a83e02a8bb9f75.tar.gz |
Properly abort a merge when merge conflicts occurreject-merge-conflicts
If somehow a user attempted to accept a merge request that had
conflicts (e.g. the "Accept Merge Request" button or the MR itself was
not updated), `MergeService` did not properly detect that a conflict
occurred. It would assume that the MR went through without any issues
and close the MR as though everything was fine. This could cause
data loss if the source branch were removed.
Closes #20425
Diffstat (limited to 'spec')
-rw-r--r-- | spec/services/merge_requests/merge_service_spec.rb | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/spec/services/merge_requests/merge_service_spec.rb b/spec/services/merge_requests/merge_service_spec.rb index f5bf3c1e367..8ffebcac698 100644 --- a/spec/services/merge_requests/merge_service_spec.rb +++ b/spec/services/merge_requests/merge_service_spec.rb @@ -75,6 +75,17 @@ describe MergeRequests::MergeService, services: true do expect(merge_request.merge_error).to eq("error") end + + it 'aborts if there is a merge conflict' do + allow_any_instance_of(Repository).to receive(:merge).and_return(false) + allow(service).to receive(:execute_hooks) + + service.execute(merge_request) + + expect(merge_request.open?).to be_truthy + expect(merge_request.merge_commit_sha).to be_nil + expect(merge_request.merge_error).to eq("Conflicts detected during merge") + end end end end |