2021-10-27 15:23:28 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require 'spec_helper'
|
|
|
|
|
2023-05-27 22:25:52 +05:30
|
|
|
RSpec.describe Sidebars::Groups::Menus::KubernetesMenu, :request_store, feature_category: :navigation do
|
2021-10-27 15:23:28 +05:30
|
|
|
let_it_be(:owner) { create(:user) }
|
|
|
|
let_it_be(:group) do
|
|
|
|
build(:group, :private).tap do |g|
|
|
|
|
g.add_owner(owner)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
let(:user) { owner }
|
|
|
|
let(:context) { Sidebars::Groups::Context.new(current_user: user, container: group) }
|
|
|
|
let(:menu) { described_class.new(context) }
|
|
|
|
|
2023-05-27 22:25:52 +05:30
|
|
|
it_behaves_like 'serializable as super_sidebar_menu_args' do
|
|
|
|
let(:extra_attrs) do
|
|
|
|
{
|
|
|
|
super_sidebar_parent: Sidebars::Groups::SuperSidebarMenus::OperationsMenu,
|
|
|
|
item_id: :group_kubernetes_clusters
|
|
|
|
}
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2021-10-27 15:23:28 +05:30
|
|
|
describe '#render?' do
|
|
|
|
context 'when user can read clusters' do
|
|
|
|
it 'returns true' do
|
|
|
|
expect(menu.render?).to eq true
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when user cannot read clusters rules' do
|
|
|
|
let(:user) { nil }
|
|
|
|
|
|
|
|
it 'returns false' do
|
|
|
|
expect(menu.render?).to eq false
|
|
|
|
end
|
|
|
|
end
|
2022-05-07 20:08:51 +05:30
|
|
|
|
|
|
|
context ':certificate_based_clusters feature flag is disabled' do
|
|
|
|
before do
|
|
|
|
stub_feature_flags(certificate_based_clusters: false)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'returns false' do
|
|
|
|
expect(menu.render?).to eq false
|
|
|
|
end
|
|
|
|
end
|
2021-10-27 15:23:28 +05:30
|
|
|
end
|
|
|
|
end
|