diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-08-19 12:08:42 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-08-19 12:08:42 +0300 |
commit | b76ae638462ab0f673e5915986070518dd3f9ad3 (patch) | |
tree | bdab0533383b52873be0ec0eb4d3c66598ff8b91 /spec/lib/sidebars/groups/menus/settings_menu_spec.rb | |
parent | 434373eabe7b4be9593d18a585fb763f1e5f1a6f (diff) |
Add latest changes from gitlab-org/gitlab@14-2-stable-eev14.2.0-rc42
Diffstat (limited to 'spec/lib/sidebars/groups/menus/settings_menu_spec.rb')
-rw-r--r-- | spec/lib/sidebars/groups/menus/settings_menu_spec.rb | 97 |
1 files changed, 97 insertions, 0 deletions
diff --git a/spec/lib/sidebars/groups/menus/settings_menu_spec.rb b/spec/lib/sidebars/groups/menus/settings_menu_spec.rb new file mode 100644 index 00000000000..314c4cdc602 --- /dev/null +++ b/spec/lib/sidebars/groups/menus/settings_menu_spec.rb @@ -0,0 +1,97 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe Sidebars::Groups::Menus::SettingsMenu do + let_it_be(:owner) { create(:user) } + + let_it_be_with_refind(: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) } + + describe '#render?' do + context 'when user cannot admin group' do + let(:user) { nil } + + it 'returns false' do + expect(menu.render?).to be false + end + end + end + + describe 'Menu items' do + subject { menu.renderable_items.find { |e| e.item_id == item_id } } + + shared_examples 'access rights checks' do + specify { is_expected.not_to be_nil } + + context 'when the user does not have access' do + let(:user) { nil } + + specify { is_expected.to be_nil } + end + end + + describe 'General menu' do + let(:item_id) { :general } + + it_behaves_like 'access rights checks' + end + + describe 'Integrations menu' do + let(:item_id) { :integrations } + + it_behaves_like 'access rights checks' + end + + describe 'Projects menu' do + let(:item_id) { :group_projects } + + it_behaves_like 'access rights checks' + end + + describe 'Repository menu' do + let(:item_id) { :repository } + + it_behaves_like 'access rights checks' + end + + describe 'CI/CD menu' do + let(:item_id) { :ci_cd } + + it_behaves_like 'access rights checks' + end + + describe 'Applications menu' do + let(:item_id) { :applications } + + it_behaves_like 'access rights checks' + end + + describe 'Packages & Registries' do + let(:item_id) { :packages_and_registries } + + before do + allow(group).to receive(:packages_feature_enabled?).and_return(packages_enabled) + end + + describe 'when packages feature is disabled' do + let(:packages_enabled) { false } + + specify { is_expected.to be_nil } + end + + describe 'when packages feature is enabled' do + let(:packages_enabled) { true } + + it_behaves_like 'access rights checks' + end + end + end +end |