From ecefe090460687a078e3d1aacf621fd5bff07fb5 Mon Sep 17 00:00:00 2001 From: Filipa Lacerda Date: Fri, 31 Aug 2018 16:58:13 +0100 Subject: Render link to branch only when branch still exists --- app/views/projects/pipelines/_info.html.haml | 6 +++++- changelogs/unreleased/42611-removed-branch-link.yml | 5 +++++ spec/features/projects/pipelines/pipeline_spec.rb | 17 +++++++++++++++++ 3 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 changelogs/unreleased/42611-removed-branch-link.yml diff --git a/app/views/projects/pipelines/_info.html.haml b/app/views/projects/pipelines/_info.html.haml index ccb83148ded..57c5f64ee8d 100644 --- a/app/views/projects/pipelines/_info.html.haml +++ b/app/views/projects/pipelines/_info.html.haml @@ -13,7 +13,11 @@ = pluralize @pipeline.total_size, "job" - if @pipeline.ref from - = link_to @pipeline.ref, project_ref_path(@project, @pipeline.ref), class: "ref-name" + - if @project.repository.branch_exists?(@pipeline.ref) + = link_to @pipeline.ref, project_ref_path(@project, @pipeline.ref), class: "ref-name" + - else + %span.ref-name + = @pipeline.ref - if @pipeline.duration in = time_interval_in_words(@pipeline.duration) diff --git a/changelogs/unreleased/42611-removed-branch-link.yml b/changelogs/unreleased/42611-removed-branch-link.yml new file mode 100644 index 00000000000..03a206871b4 --- /dev/null +++ b/changelogs/unreleased/42611-removed-branch-link.yml @@ -0,0 +1,5 @@ +--- +title: Only render link to branch when branch still exists in pipeline page +merge_request: +author: +type: fixed diff --git a/spec/features/projects/pipelines/pipeline_spec.rb b/spec/features/projects/pipelines/pipeline_spec.rb index 603503a531c..4d659cb988e 100644 --- a/spec/features/projects/pipelines/pipeline_spec.rb +++ b/spec/features/projects/pipelines/pipeline_spec.rb @@ -63,6 +63,11 @@ describe 'Pipeline', :js do expect(page).to have_css('#js-tab-pipeline.active') end + it 'shows link to the pipeline ref' do + expect(page).to have_link(pipeline.ref) + end + + it_behaves_like 'showing user status' do let(:user_with_status) { pipeline.user } @@ -208,6 +213,18 @@ describe 'Pipeline', :js do it { expect(page).not_to have_content('Cancel running') } end end + + context 'with deleted branch' do + before do + DeleteBranchService.new(@project, @user).execute(pipeline.ref) + end + + it 'does not render link to the pipeline ref' do + expect(page).not_to have_link(pipeline.ref) + expect(page).to have_content(pipeline.ref) + end + end + end context 'when user does not have access to read jobs' do -- cgit v1.2.1