From 0d583e5e8a36231eef614305208ea67ab91a5b62 Mon Sep 17 00:00:00 2001 From: Filipa Lacerda Date: Mon, 8 Oct 2018 16:55:13 +0100 Subject: [PATCH] Creates ref_exists? method for Pipeline class --- app/models/ci/pipeline.rb | 4 ++++ app/views/projects/pipelines/_info.html.haml | 2 +- spec/features/projects/pipelines/pipeline_spec.rb | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/app/models/ci/pipeline.rb b/app/models/ci/pipeline.rb index 17024e8a0af..c53b14bd406 100644 --- a/app/models/ci/pipeline.rb +++ b/app/models/ci/pipeline.rb @@ -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. diff --git a/app/views/projects/pipelines/_info.html.haml b/app/views/projects/pipelines/_info.html.haml index 57c5f64ee8d..ba7f542f68e 100644 --- a/app/views/projects/pipelines/_info.html.haml +++ b/app/views/projects/pipelines/_info.html.haml @@ -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 diff --git a/spec/features/projects/pipelines/pipeline_spec.rb b/spec/features/projects/pipelines/pipeline_spec.rb index 8cdefebd4ce..a79dbe7f877 100644 --- a/spec/features/projects/pipelines/pipeline_spec.rb +++ b/spec/features/projects/pipelines/pipeline_spec.rb @@ -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 -- GitLab