diff options
author | Oswaldo Ferreira <oswaldo@gitlab.com> | 2019-06-20 20:38:28 +0300 |
---|---|---|
committer | Oswaldo Ferreira <oswaldo@gitlab.com> | 2019-06-20 20:47:34 +0300 |
commit | 1f0b50c418c35a6a6978d148fdb5389fd2b3d0c7 (patch) | |
tree | 2936ea66caed8167966ad58c0162cc2982b8ba92 /spec/services/merge_requests/mergeability_check_service_spec.rb | |
parent | 3af348b6cf28ef1d9d3025f7012049132b57798c (diff) |
Only force recheck when merge-ref is outdated
When recheck flag is true, we make sure the merge-ref
is indeed outdated. If it is, we update it along
the merge status.
Diffstat (limited to 'spec/services/merge_requests/mergeability_check_service_spec.rb')
-rw-r--r-- | spec/services/merge_requests/mergeability_check_service_spec.rb | 45 |
1 files changed, 44 insertions, 1 deletions
diff --git a/spec/services/merge_requests/mergeability_check_service_spec.rb b/spec/services/merge_requests/mergeability_check_service_spec.rb index c5fe51b79f2..6c04e816b91 100644 --- a/spec/services/merge_requests/mergeability_check_service_spec.rb +++ b/spec/services/merge_requests/mergeability_check_service_spec.rb @@ -91,7 +91,7 @@ describe MergeRequests::MergeabilityCheckService do expect(result.payload).to be_empty end - it 'updates the merge_status' do + it 'ignores merge-ref and updates merge status' do expect { subject }.to change(merge_request, :merge_status).from('unchecked').to('can_be_merged') end end @@ -206,6 +206,28 @@ describe MergeRequests::MergeabilityCheckService do context 'recheck enforced' do subject { described_class.new(merge_request).execute(recheck: true) } + context 'when MR is mergeable and merge-ref auto-sync is disabled' do + before do + stub_feature_flags(merge_ref_auto_sync: false) + merge_request.mark_as_mergeable! + 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 is outdated due to disabled feature') + expect(result.payload).to be_empty + end + + it 'merge status is not changed' do + subject + + expect(merge_request.merge_status).to eq('can_be_merged') + end + end + context 'when MR is mergeable but merge-ref does not exists' do before do merge_request.mark_as_mergeable! @@ -213,6 +235,27 @@ describe MergeRequests::MergeabilityCheckService do it_behaves_like 'mergeable merge request' end + + context 'when MR is mergeable but merge-ref is already updated' do + before do + MergeRequests::MergeToRefService.new(project, merge_request.author).execute(merge_request) + merge_request.mark_as_mergeable! + end + + it 'returns ServiceResponse.success' do + result = subject + + expect(result).to be_a(ServiceResponse) + expect(result).to be_success + expect(result.payload[:merge_ref_head]).to be_present + end + + it 'does not recreate the merge-ref' do + expect(MergeRequests::MergeToRefService).not_to receive(:new) + + subject + end + end end end end |