Creates ref_exists? method for Pipeline class

This commit is contained in:
Filipa Lacerda 2018-10-08 16:55:13 +01:00
parent fa875ba7a9
commit 0d583e5e8a
3 changed files with 6 additions and 2 deletions

View File

@ -268,6 +268,10 @@ module Ci
stage unless stage.statuses_count.zero?
end
def ref_exists?
project.repository.ref_exists?(self.ref)
end
##
# TODO We do not completely switch to persisted stages because of
# race conditions with setting statuses gitlab-ce#23257.

View File

@ -13,7 +13,7 @@
= pluralize @pipeline.total_size, "job"
- if @pipeline.ref
from
- if @project.repository.branch_exists?(@pipeline.ref)
- if @pipeline.ref_exists?
= link_to @pipeline.ref, project_ref_path(@project, @pipeline.ref), class: "ref-name"
- else
%span.ref-name

View File

@ -244,7 +244,7 @@ describe 'Pipeline', :js do
context 'with deleted branch' do
before do
DeleteBranchService.new(@project, @user).execute(pipeline.ref)
allow(pipeline).to receive(:ref_exists?).and_return(false)
end
it 'does not render link to the pipeline ref' do