Commit 48c95031 authored by Frédéric Caplette's avatar Frédéric Caplette

Keep branch when going to Pipeline Editor through nav

When going to the pipeline editor through the menu, we
should preserve the branch the user was currently on.
This now passes the current ref in the nav item
so that we can load the right ref context right
when arriving in the pipeline editor.

Changelog: changed
parent 762d9a60
......@@ -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