diff options
author | Oswaldo Ferreira <oswaldo@gitlab.com> | 2018-01-29 15:56:19 +0000 |
---|---|---|
committer | Rémy Coutable <remy@rymai.me> | 2018-01-29 15:56:19 +0000 |
commit | df44c59050b10d9312081782c1620aaf9969dcf8 (patch) | |
tree | 0644e5d6b213eb9dfd3a12ad5830886500e243e0 /spec/services | |
parent | f195ac03f2306cab53d55984bc469591f22b7382 (diff) | |
download | gitlab-ce-df44c59050b10d9312081782c1620aaf9969dcf8.tar.gz |
Close and do not reload MR diffs when source branch is deleted
Diffstat (limited to 'spec/services')
-rw-r--r-- | spec/services/merge_requests/refresh_service_spec.rb | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/spec/services/merge_requests/refresh_service_spec.rb b/spec/services/merge_requests/refresh_service_spec.rb index 7a01d3dd698..7c3374c6113 100644 --- a/spec/services/merge_requests/refresh_service_spec.rb +++ b/spec/services/merge_requests/refresh_service_spec.rb @@ -55,11 +55,12 @@ describe MergeRequests::RefreshService do before do allow(refresh_service).to receive(:execute_hooks) - refresh_service.execute(@oldrev, @newrev, 'refs/heads/master') - reload_mrs end it 'executes hooks with update action' do + refresh_service.execute(@oldrev, @newrev, 'refs/heads/master') + reload_mrs + expect(refresh_service).to have_received(:execute_hooks) .with(@merge_request, 'update', old_rev: @oldrev) @@ -72,6 +73,26 @@ describe MergeRequests::RefreshService do expect(@build_failed_todo).to be_done expect(@fork_build_failed_todo).to be_done end + + context 'when source branch ref does not exists' do + before do + DeleteBranchService.new(@project, @user).execute(@merge_request.source_branch) + end + + it 'closes MRs without source branch ref' do + expect { refresh_service.execute(@oldrev, @newrev, 'refs/heads/master') } + .to change { @merge_request.reload.state } + .from('opened') + .to('closed') + + expect(@fork_merge_request.reload).to be_open + end + + it 'does not change the merge request diff' do + expect { refresh_service.execute(@oldrev, @newrev, 'refs/heads/master') } + .not_to change { @merge_request.reload.merge_request_diff } + end + end end context 'when pipeline exists for the source branch' do |