diff options
Diffstat (limited to 'spec/lib/sidebars')
5 files changed, 92 insertions, 31 deletions
diff --git a/spec/lib/sidebars/groups/menus/packages_registries_menu_spec.rb b/spec/lib/sidebars/groups/menus/packages_registries_menu_spec.rb index c5666724acf..ce368ad5bd6 100644 --- a/spec/lib/sidebars/groups/menus/packages_registries_menu_spec.rb +++ b/spec/lib/sidebars/groups/menus/packages_registries_menu_spec.rb @@ -207,6 +207,16 @@ RSpec.describe Sidebars::Groups::Menus::PackagesRegistriesMenu do it_behaves_like 'the menu entry is available' end + + context 'when config harbor registry setting is not activated' do + before do + harbor_integration.update!(active: false) + end + + let(:harbor_registry_enabled) { true } + + it_behaves_like 'the menu entry is not available' + end end end diff --git a/spec/lib/sidebars/projects/menus/analytics_menu_spec.rb b/spec/lib/sidebars/projects/menus/analytics_menu_spec.rb index 25a65015847..878da747abe 100644 --- a/spec/lib/sidebars/projects/menus/analytics_menu_spec.rb +++ b/spec/lib/sidebars/projects/menus/analytics_menu_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' RSpec.describe Sidebars::Projects::Menus::AnalyticsMenu do - let_it_be(:project) { create(:project, :repository) } + let_it_be_with_refind(:project) { create(:project, :repository) } let_it_be(:guest) do create(:user).tap { |u| project.add_guest(u) } end @@ -125,6 +125,34 @@ RSpec.describe Sidebars::Projects::Menus::AnalyticsMenu do specify { is_expected.to be_nil } end + + describe 'when issues are disabled' do + before do + project.issues_enabled = false + project.save! + end + + specify { is_expected.not_to be_nil } + end + + describe 'when merge requests are disabled' do + before do + project.merge_requests_enabled = false + project.save! + end + + specify { is_expected.not_to be_nil } + end + + describe 'when the issues and merge requests are disabled' do + before do + project.issues_enabled = false + project.merge_requests_enabled = false + project.save! + end + + specify { is_expected.to be_nil } + end end end end diff --git a/spec/lib/sidebars/projects/menus/deployments_menu_spec.rb b/spec/lib/sidebars/projects/menus/deployments_menu_spec.rb index 90ff04a2064..685ba0c31c7 100644 --- a/spec/lib/sidebars/projects/menus/deployments_menu_spec.rb +++ b/spec/lib/sidebars/projects/menus/deployments_menu_spec.rb @@ -45,30 +45,30 @@ RSpec.describe Sidebars::Projects::Menus::DeploymentsMenu do it { is_expected.to be_nil } end + end + + shared_examples 'split_operations_visibility_permissions FF disabled' do + before do + stub_feature_flags(split_operations_visibility_permissions: false) + end - describe 'when split_operations_visibility_permissions FF is disabled' do + it { is_expected.not_to be_nil } + + context 'and the feature is disabled' do before do - stub_feature_flags(split_operations_visibility_permissions: false) + project.update_attribute("#{item_id}_access_level", 'disabled') end it { is_expected.not_to be_nil } + end - context 'and the feature is disabled' do - before do - project.update_attribute("#{item_id}_access_level", 'disabled') - end - - it { is_expected.not_to be_nil } + context 'and operations is disabled' do + before do + project.update_attribute(:operations_access_level, 'disabled') end - context 'and operations is disabled' do - before do - project.update_attribute(:operations_access_level, 'disabled') - end - - it do - is_expected.to be_nil if [:environments, :feature_flags].include?(item_id) - end + it do + is_expected.to be_nil if [:environments, :feature_flags].include?(item_id) end end end @@ -77,12 +77,14 @@ RSpec.describe Sidebars::Projects::Menus::DeploymentsMenu do let(:item_id) { :feature_flags } it_behaves_like 'access rights checks' + it_behaves_like 'split_operations_visibility_permissions FF disabled' end describe 'Environments' do let(:item_id) { :environments } it_behaves_like 'access rights checks' + it_behaves_like 'split_operations_visibility_permissions FF disabled' end describe 'Releases' do diff --git a/spec/lib/sidebars/projects/menus/packages_registries_menu_spec.rb b/spec/lib/sidebars/projects/menus/packages_registries_menu_spec.rb index 6491ef823e9..b03269c424a 100644 --- a/spec/lib/sidebars/projects/menus/packages_registries_menu_spec.rb +++ b/spec/lib/sidebars/projects/menus/packages_registries_menu_spec.rb @@ -67,7 +67,7 @@ RSpec.describe Sidebars::Projects::Menus::PackagesRegistriesMenu do describe 'Packages Registry' do let(:item_id) { :packages_registry } - shared_examples 'when user can read packages' do + context 'when user can read packages' do context 'when config package setting is disabled' do it 'the menu item is not added to list of menu items' do stub_config(packages: { enabled: false }) @@ -85,25 +85,13 @@ RSpec.describe Sidebars::Projects::Menus::PackagesRegistriesMenu do end end - shared_examples 'when user cannot read packages' do + context 'when user cannot read packages' do let(:user) { nil } it 'the menu item is not added to list of menu items' do is_expected.to be_nil end end - - it_behaves_like 'when user can read packages' - it_behaves_like 'when user cannot read packages' - - context 'with feature flag disabled' do - before do - stub_feature_flags(read_package_policy_rule: false) - end - - it_behaves_like 'when user can read packages' - it_behaves_like 'when user cannot read packages' - end end describe 'Container Registry' do @@ -178,6 +166,15 @@ RSpec.describe Sidebars::Projects::Menus::PackagesRegistriesMenu do is_expected.not_to be_nil end end + + context 'when config harbor registry setting is not activated' do + it 'does not add the menu item to the list' do + stub_feature_flags(harbor_registry_integration: true) + project.harbor_integration.update!(active: false) + + is_expected.to be_nil + end + end end end end diff --git a/spec/lib/sidebars/projects/menus/repository_menu_spec.rb b/spec/lib/sidebars/projects/menus/repository_menu_spec.rb index fc181947e60..f26433306b6 100644 --- a/spec/lib/sidebars/projects/menus/repository_menu_spec.rb +++ b/spec/lib/sidebars/projects/menus/repository_menu_spec.rb @@ -34,5 +34,29 @@ RSpec.describe Sidebars::Projects::Menus::RepositoryMenu do end end end + + context 'for menu items' do + subject { described_class.new(context).renderable_items.index { |e| e.item_id == item_id } } + + describe 'Contributors' do + let_it_be(:item_id) { :contributors } + + context 'when analytics is disabled' do + before do + project.project_feature.update!(analytics_access_level: ProjectFeature::DISABLED) + end + + it { is_expected.to be_nil } + end + + context 'when analytics is enabled' do + before do + project.project_feature.update!(analytics_access_level: ProjectFeature::ENABLED) + end + + it { is_expected.not_to be_nil } + end + end + end end end |