diff options
Diffstat (limited to 'spec/lib/sidebars')
6 files changed, 47 insertions, 5 deletions
diff --git a/spec/lib/sidebars/groups/menus/observability_menu_spec.rb b/spec/lib/sidebars/groups/menus/observability_menu_spec.rb index 3a91b1aea2f..5b993cd6f28 100644 --- a/spec/lib/sidebars/groups/menus/observability_menu_spec.rb +++ b/spec/lib/sidebars/groups/menus/observability_menu_spec.rb @@ -20,23 +20,25 @@ RSpec.describe Sidebars::Groups::Menus::ObservabilityMenu do allow(menu).to receive(:can?).and_call_original end - context 'when user can :read_observability' do + context 'when observability is enabled' do before do - allow(menu).to receive(:can?).with(user, :read_observability, group).and_return(true) + allow(Gitlab::Observability).to receive(:observability_enabled?).and_return(true) end it 'returns true' do expect(menu.render?).to eq true + expect(Gitlab::Observability).to have_received(:observability_enabled?).with(user, group) end end - context 'when user cannot :read_observability' do + context 'when observability is disabled' do before do - allow(menu).to receive(:can?).with(user, :read_observability, group).and_return(false) + allow(Gitlab::Observability).to receive(:observability_enabled?).and_return(false) end it 'returns false' do expect(menu.render?).to eq false + expect(Gitlab::Observability).to have_received(:observability_enabled?).with(user, group) end end end diff --git a/spec/lib/sidebars/groups/menus/settings_menu_spec.rb b/spec/lib/sidebars/groups/menus/settings_menu_spec.rb index 4e3c639672b..c5246fe93dd 100644 --- a/spec/lib/sidebars/groups/menus/settings_menu_spec.rb +++ b/spec/lib/sidebars/groups/menus/settings_menu_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe Sidebars::Groups::Menus::SettingsMenu do +RSpec.describe Sidebars::Groups::Menus::SettingsMenu, :with_license do let_it_be(:owner) { create(:user) } let_it_be_with_refind(:group) do diff --git a/spec/lib/sidebars/projects/menus/settings_menu_spec.rb b/spec/lib/sidebars/projects/menus/settings_menu_spec.rb index 0733e0c6521..c7aca0fb97e 100644 --- a/spec/lib/sidebars/projects/menus/settings_menu_spec.rb +++ b/spec/lib/sidebars/projects/menus/settings_menu_spec.rb @@ -10,6 +10,10 @@ RSpec.describe Sidebars::Projects::Menus::SettingsMenu do subject { described_class.new(context) } + before do + stub_feature_flags(show_pages_in_deployments_menu: false) + end + describe '#render?' do it 'returns false when menu does not have any menu items' do allow(subject).to receive(:has_renderable_items?).and_return(false) diff --git a/spec/lib/sidebars/your_work/menus/issues_menu_spec.rb b/spec/lib/sidebars/your_work/menus/issues_menu_spec.rb new file mode 100644 index 00000000000..a1206c0bc1c --- /dev/null +++ b/spec/lib/sidebars/your_work/menus/issues_menu_spec.rb @@ -0,0 +1,12 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe Sidebars::YourWork::Menus::IssuesMenu, feature_category: :navigation do + let(:user) { create(:user) } + let(:context) { Sidebars::Context.new(current_user: user, container: nil) } + + subject { described_class.new(context) } + + include_examples 'menu item shows pill based on count', :assigned_open_issues_count +end diff --git a/spec/lib/sidebars/your_work/menus/merge_requests_menu_spec.rb b/spec/lib/sidebars/your_work/menus/merge_requests_menu_spec.rb new file mode 100644 index 00000000000..b3251a54178 --- /dev/null +++ b/spec/lib/sidebars/your_work/menus/merge_requests_menu_spec.rb @@ -0,0 +1,12 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe Sidebars::YourWork::Menus::MergeRequestsMenu, feature_category: :navigation do + let(:user) { create(:user) } + let(:context) { Sidebars::Context.new(current_user: user, container: nil) } + + subject { described_class.new(context) } + + include_examples 'menu item shows pill based on count', :assigned_open_merge_requests_count +end diff --git a/spec/lib/sidebars/your_work/menus/todos_menu_spec.rb b/spec/lib/sidebars/your_work/menus/todos_menu_spec.rb new file mode 100644 index 00000000000..a8177a6a01b --- /dev/null +++ b/spec/lib/sidebars/your_work/menus/todos_menu_spec.rb @@ -0,0 +1,12 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe Sidebars::YourWork::Menus::TodosMenu, feature_category: :navigation do + let(:user) { create(:user) } + let(:context) { Sidebars::Context.new(current_user: user, container: nil) } + + subject { described_class.new(context) } + + include_examples 'menu item shows pill based on count', :todos_pending_count +end |