diff options
Diffstat (limited to 'spec/lib/sidebars/groups')
3 files changed, 46 insertions, 1 deletions
diff --git a/spec/lib/sidebars/groups/menus/observability_menu_spec.rb b/spec/lib/sidebars/groups/menus/observability_menu_spec.rb new file mode 100644 index 00000000000..3a91b1aea2f --- /dev/null +++ b/spec/lib/sidebars/groups/menus/observability_menu_spec.rb @@ -0,0 +1,43 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe Sidebars::Groups::Menus::ObservabilityMenu do + let_it_be(:owner) { create(:user) } + let_it_be(:root_group) do + build(:group, :private).tap do |g| + g.add_owner(owner) + end + end + + let(:group) { root_group } + let(:user) { owner } + let(:context) { Sidebars::Groups::Context.new(current_user: user, container: group) } + let(:menu) { described_class.new(context) } + + describe '#render?' do + before do + allow(menu).to receive(:can?).and_call_original + end + + context 'when user can :read_observability' do + before do + allow(menu).to receive(:can?).with(user, :read_observability, group).and_return(true) + end + + it 'returns true' do + expect(menu.render?).to eq true + end + end + + context 'when user cannot :read_observability' do + before do + allow(menu).to receive(:can?).with(user, :read_observability, group).and_return(false) + end + + it 'returns false' do + expect(menu.render?).to eq false + end + end + end +end 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 d3cb18222b5..c5666724acf 100644 --- a/spec/lib/sidebars/groups/menus/packages_registries_menu_spec.rb +++ b/spec/lib/sidebars/groups/menus/packages_registries_menu_spec.rb @@ -10,6 +10,8 @@ RSpec.describe Sidebars::Groups::Menus::PackagesRegistriesMenu do end end + let_it_be(:harbor_integration) { create(:harbor_integration, group: group, project: nil) } + let(:user) { owner } let(:context) { Sidebars::Groups::Context.new(current_user: user, container: group) } let(:menu) { described_class.new(context) } diff --git a/spec/lib/sidebars/groups/menus/settings_menu_spec.rb b/spec/lib/sidebars/groups/menus/settings_menu_spec.rb index 252da8ea699..4e3c639672b 100644 --- a/spec/lib/sidebars/groups/menus/settings_menu_spec.rb +++ b/spec/lib/sidebars/groups/menus/settings_menu_spec.rb @@ -80,7 +80,7 @@ RSpec.describe Sidebars::Groups::Menus::SettingsMenu do it_behaves_like 'access rights checks' end - describe 'Packages & Registries' do + describe 'Packages and registries' do let(:item_id) { :packages_and_registries } before do |