From 5632079c3684562aea890123182bd43648149b55 Mon Sep 17 00:00:00 2001 From: Stan Hu Date: Tue, 14 May 2019 14:37:15 -0500 Subject: Properly clear the merge error upon rebase failure If `merge_error` is ever set after a failure, it is never cleared, even after a subsequent, successful rebase. We now clear this field whenever a successful rebase occurs. Closes https://gitlab.com/gitlab-org/gitlab-ce/issues/56139 --- .../services/merge_requests/rebase_service_spec.rb | 26 ++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'spec') diff --git a/spec/services/merge_requests/rebase_service_spec.rb b/spec/services/merge_requests/rebase_service_spec.rb index a443e4588d9..0c4433453ac 100644 --- a/spec/services/merge_requests/rebase_service_spec.rb +++ b/spec/services/merge_requests/rebase_service_spec.rb @@ -38,6 +38,32 @@ describe MergeRequests::RebaseService do end end + shared_examples 'sequence of failure and success' do + it 'properly clears the error message' do + allow(repository).to receive(:gitaly_operation_client).and_raise('Something went wrong') + + service.execute(merge_request) + + expect(merge_request.reload.merge_error).to eq described_class::REBASE_ERROR + + allow(repository).to receive(:gitaly_operation_client).and_call_original + + service.execute(merge_request) + + expect(merge_request.reload.merge_error).to eq nil + end + end + + it_behaves_like 'sequence of failure and success' + + context 'with deprecated step rebase feature' do + before do + allow(Feature).to receive(:disabled?).with(:two_step_rebase, anything).and_return(true) + end + + it_behaves_like 'sequence of failure and success' + end + context 'when unexpected error occurs' do before do allow(repository).to receive(:gitaly_operation_client).and_raise('Something went wrong') -- cgit v1.2.1