summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFilipa Lacerda <filipa@gitlab.com>2018-08-31 16:58:13 +0100
committerFilipa Lacerda <filipa@gitlab.com>2018-08-31 16:59:23 +0100
commitecefe090460687a078e3d1aacf621fd5bff07fb5 (patch)
treecc60b6d66838da18474144556673be1175f7a51d
parent472f2d566633df6c1dee1f703b06958b9a0a2cd8 (diff)
downloadgitlab-ce-ecefe090460687a078e3d1aacf621fd5bff07fb5.tar.gz
Render link to branch only when branch still exists
-rw-r--r--app/views/projects/pipelines/_info.html.haml6
-rw-r--r--changelogs/unreleased/42611-removed-branch-link.yml5
-rw-r--r--spec/features/projects/pipelines/pipeline_spec.rb17
3 files changed, 27 insertions, 1 deletions
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