Commit 8055de72 authored by Corinna Wiesner's avatar Corinna Wiesner Committed by Andrew Fontaine

Activate correct nav item for Admin::LicensesController

With the removal of the old license page, the remaining actions have to
activate the correct nav item.

Changelog: fixed
MR: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/66051
EE: true
parent e480aa14
= nav_link(controller: 'admin/subscriptions') do = nav_link(controller: ['admin/subscriptions', 'admin/licenses']) do
= link_to admin_subscription_path, class: "qa-link-subscription-menu" do = link_to admin_subscription_path, class: "qa-link-subscription-menu" do
.nav-icon-container .nav-icon-container
= sprite_icon('license') = sprite_icon('license')
%span.nav-item-name %span.nav-item-name
= _('Subscription') = _('Subscription')
%ul.sidebar-sub-level-items.is-fly-out-only %ul.sidebar-sub-level-items.is-fly-out-only
= nav_link(controller: controller, html_options: { class: "fly-out-top-item" } ) do = nav_link(controller: ['admin/subscriptions', 'admin/licenses'], html_options: { class: "fly-out-top-item" } ) do
= link_to admin_subscription_path do = link_to admin_subscription_path do
%strong.fly-out-top-item-name %strong.fly-out-top-item-name
= _('Subscription') = _('Subscription')
...@@ -43,12 +43,20 @@ RSpec.describe "Admin uploads license", :js do ...@@ -43,12 +43,20 @@ RSpec.describe "Admin uploads license", :js do
File.write(path, license.export) File.write(path, license.export)
end end
shared_examples 'active navigation item' do
it 'activates the "Subscription" navigation item' do
expect(find('.sidebar-top-level-items > li.active')).to have_content('Subscription')
end
end
context "when license is valid" do context "when license is valid" do
let_it_be(:path) { Rails.root.join("tmp/valid_license.gitlab-license") } let_it_be(:path) { Rails.root.join("tmp/valid_license.gitlab-license") }
context "when license is active immediately" do context "when license is active immediately" do
let_it_be(:license) { build(:gitlab_license) } let_it_be(:license) { build(:gitlab_license) }
it_behaves_like 'active navigation item'
it "uploads license" do it "uploads license" do
attach_and_upload(path) attach_and_upload(path)
...@@ -61,6 +69,8 @@ RSpec.describe "Admin uploads license", :js do ...@@ -61,6 +69,8 @@ RSpec.describe "Admin uploads license", :js do
let_it_be(:license) { build(:gitlab_license, starts_at: Date.current + 1.month) } let_it_be(:license) { build(:gitlab_license, starts_at: Date.current + 1.month) }
context "when a current license exists" do context "when a current license exists" do
it_behaves_like 'active navigation item'
it "uploads license" do it "uploads license" do
attach_and_upload(path) attach_and_upload(path)
...@@ -74,6 +84,8 @@ RSpec.describe "Admin uploads license", :js do ...@@ -74,6 +84,8 @@ RSpec.describe "Admin uploads license", :js do
allow(License).to receive(:current).and_return(nil) allow(License).to receive(:current).and_return(nil)
end end
it_behaves_like 'active navigation item'
it "uploads license" do it "uploads license" do
attach_and_upload(path) attach_and_upload(path)
...@@ -87,6 +99,8 @@ RSpec.describe "Admin uploads license", :js do ...@@ -87,6 +99,8 @@ RSpec.describe "Admin uploads license", :js do
let_it_be(:license) { build(:gitlab_license, expires_at: Date.yesterday) } let_it_be(:license) { build(:gitlab_license, expires_at: Date.yesterday) }
let_it_be(:path) { Rails.root.join("tmp/invalid_license.gitlab-license") } let_it_be(:path) { Rails.root.join("tmp/invalid_license.gitlab-license") }
it_behaves_like 'active navigation item'
it "doesn't upload license" do it "doesn't upload license" do
attach_and_upload(path) attach_and_upload(path)
......
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