Commit e06ce1e1 authored by Max Woolf's avatar Max Woolf

Merge branch...

Merge branch '348792-ci-cd-editor-should-render-the-gitlab-ci-for-the-branch-from-which-the-menu-is-being-accessed' into 'master'

CI/CD editor nav link should maintain current branch

See merge request gitlab-org/gitlab!78594
parents 7bb52a0e 48c95031
......@@ -5,7 +5,7 @@ require 'spec_helper'
RSpec.describe Sidebars::Projects::Menus::CiCdMenu do
let(:project) { build(:project) }
let(:user) { project.owner }
let(:context) { Sidebars::Projects::Context.new(current_user: user, container: project, can_view_pipeline_editor: true) }
let(:context) { Sidebars::Projects::Context.new(current_user: user, current_ref: 'main', container: project, can_view_pipeline_editor: true) }
describe 'Test Cases' do
subject { described_class.new(context).renderable_items.index { |e| e.item_id == :test_cases} }
......
......@@ -68,9 +68,13 @@ module Sidebars
return ::Sidebars::NilMenuItem.new(item_id: :pipelines_editor)
end
params = {
branch_name: context.current_ref || context.project.default_branch
}
::Sidebars::MenuItem.new(
title: s_('Pipelines|Editor'),
link: project_ci_pipeline_editor_path(context.project),
link: project_ci_pipeline_editor_path(context.project, params),
active_routes: { path: 'projects/ci/pipeline_editor#show' },
item_id: :pipelines_editor
)
......
......@@ -286,10 +286,20 @@ RSpec.describe 'layouts/nav/sidebar/_project' do
end
describe 'Pipeline Editor' do
it 'has a link to the pipeline editor' do
render
context 'with a current_ref' do
it 'has a link to the pipeline editor' do
render
expect(rendered).to have_link('Editor', href: project_ci_pipeline_editor_path(project, params: { branch_name: current_ref }))
end
end
context 'with the default_branch' do
it 'has a link to the pipeline editor' do
render
expect(rendered).to have_link('Editor', href: project_ci_pipeline_editor_path(project))
expect(rendered).to have_link('Editor', href: project_ci_pipeline_editor_path(project, params: { branch_name: project.default_branch }))
end
end
context 'when user cannot access pipeline editor' do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment