diff options
Diffstat (limited to 'spec/lib/sidebars/organizations/menus/manage_menu_spec.rb')
-rw-r--r-- | spec/lib/sidebars/organizations/menus/manage_menu_spec.rb | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/spec/lib/sidebars/organizations/menus/manage_menu_spec.rb b/spec/lib/sidebars/organizations/menus/manage_menu_spec.rb index 87346176a4c..7f1dab6a8b4 100644 --- a/spec/lib/sidebars/organizations/menus/manage_menu_spec.rb +++ b/spec/lib/sidebars/organizations/menus/manage_menu_spec.rb @@ -7,17 +7,15 @@ RSpec.describe Sidebars::Organizations::Menus::ManageMenu, feature_category: :na let_it_be(:user) { build(:user) } let_it_be(:context) { Sidebars::Context.new(current_user: user, container: organization) } - let(:items) { subject.instance_variable_get(:@items) } - - subject { described_class.new(context) } + subject(:menu) { described_class.new(context) } it 'has title and sprite_icon' do - expect(subject.title).to eq(s_("Navigation|Manage")) - expect(subject.sprite_icon).to eq("users") + expect(menu.title).to eq(s_("Navigation|Manage")) + expect(menu.sprite_icon).to eq("users") end describe 'Menu items' do - subject { described_class.new(context).renderable_items.find { |e| e.item_id == item_id } } + subject(:item) { menu.renderable_items.find { |e| e.item_id == item_id } } describe 'Groups and projects' do let(:item_id) { :organization_groups_and_projects } @@ -28,7 +26,15 @@ RSpec.describe Sidebars::Organizations::Menus::ManageMenu, feature_category: :na describe 'Users' do let(:item_id) { :organization_users } - it { is_expected.not_to be_nil } + context 'when current user has permissions' do + let_it_be(:organization_user) { create(:organization_user, user: user, organization: organization) } # rubocop: disable RSpec/FactoryBot/AvoidCreate -- does not work with build_stubbed + + it { is_expected.not_to be_nil } + end + + context 'when current user does not have permissions' do + it { is_expected.to be_nil } + end end end end |