From cfe3658a2fa2838af097b490fc9cc1b8ebdc1cbc Mon Sep 17 00:00:00 2001 From: Aaron Dewes <aaron.dewes@protonmail.com> Date: Fri, 18 Aug 2023 14:07:28 +0000 Subject: [PATCH] Only include branch name pipeline editor link Changelog: fixed --- app/presenters/blob_presenter.rb | 2 +- spec/presenters/blob_presenter_spec.rb | 12 +++++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/app/presenters/blob_presenter.rb b/app/presenters/blob_presenter.rb index f58ba2b3eaf38..5699389e0005c 100644 --- a/app/presenters/blob_presenter.rb +++ b/app/presenters/blob_presenter.rb @@ -77,7 +77,7 @@ def replace_path end def pipeline_editor_path - project_ci_pipeline_editor_path(project, branch_name: blob.commit_id) if can_collaborate_with_project?(project) && blob.path == project.ci_config_path_or_default + project_ci_pipeline_editor_path(project, branch_name: commit_id) if can_collaborate_with_project?(project) && blob.path == project.ci_config_path_or_default end def gitpod_blob_url diff --git a/spec/presenters/blob_presenter_spec.rb b/spec/presenters/blob_presenter_spec.rb index 00a2c218466d9..12f3b4bb94a50 100644 --- a/spec/presenters/blob_presenter_spec.rb +++ b/spec/presenters/blob_presenter_spec.rb @@ -130,7 +130,7 @@ describe '#pipeline_editor_path' do context 'when blob is .gitlab-ci.yml' do - before do + before_all do project.repository.create_file( user, '.gitlab-ci.yml', @@ -144,6 +144,16 @@ let(:path) { '.gitlab-ci.yml' } it { expect(presenter.pipeline_editor_path).to eq("/#{project.full_path}/-/ci/editor?branch_name=#{ref}") } + + context 'when ref includes the qualifier' do + let(:ref) { 'refs/heads/main' } + + it 'returns path to unqualified ref' do + allow(blob).to receive(:ref_type).and_return('heads') + + expect(presenter.pipeline_editor_path).to eq("/#{project.full_path}/-/ci/editor?branch_name=main") + end + end end end -- GitLab