diff options
author | Oswaldo Ferreira <oswaldo@gitlab.com> | 2019-06-21 11:30:09 -0300 |
---|---|---|
committer | Oswaldo Ferreira <oswaldo@gitlab.com> | 2019-06-21 11:30:09 -0300 |
commit | 74a3e6b71254409d423077987f6961ea17ba00d9 (patch) | |
tree | 363623559c3f289ce55beec3a6f5b2c363a563f8 /spec/services | |
parent | 710a660ec3a76d34b9bf69e2a8c9afd51454efa7 (diff) | |
download | gitlab-ce-74a3e6b71254409d423077987f6961ea17ba00d9.tar.gz |
Avoid touching the MR status if MR is not opened
Diffstat (limited to 'spec/services')
-rw-r--r-- | spec/services/merge_requests/mergeability_check_service_spec.rb | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/spec/services/merge_requests/mergeability_check_service_spec.rb b/spec/services/merge_requests/mergeability_check_service_spec.rb index 6c04e816b91..6efece64092 100644 --- a/spec/services/merge_requests/mergeability_check_service_spec.rb +++ b/spec/services/merge_requests/mergeability_check_service_spec.rb @@ -228,6 +228,30 @@ describe MergeRequests::MergeabilityCheckService do end end + context 'when MR is marked as mergeable, but repo is not mergeable and MR is not opened' do + before do + # Making sure that we don't touch the merge-status after + # the MR is not opened any longer. Source branch might + # have been removed, etc. + allow(merge_request).to receive(:broken?) { true } + merge_request.mark_as_mergeable! + merge_request.close! + end + + it 'returns ServiceResponse.error' do + result = subject + + expect(result).to be_a(ServiceResponse) + expect(result.error?).to be(true) + expect(result.message).to eq('Merge ref cannot be updated') + expect(result.payload).to be_empty + end + + it 'does not change the merge status' do + expect { subject }.not_to change(merge_request, :merge_status).from('can_be_merged') + end + end + context 'when MR is mergeable but merge-ref does not exists' do before do merge_request.mark_as_mergeable! |