diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-11-17 09:12:07 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-11-17 09:12:07 +0300 |
commit | 8624e54ae69729abf8664f1f1a57e90ee9ecab1a (patch) | |
tree | 5a582393864f83a1ae05b8c3cdcbc7e4de57f5b2 /spec/lib | |
parent | f8edb3a740b9ba434489a50b69c2e765cecb24b0 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/lib')
-rw-r--r-- | spec/lib/sidebars/groups/menus/invite_team_members_menu_spec.rb | 55 | ||||
-rw-r--r-- | spec/lib/sidebars/projects/menus/invite_team_members_menu_spec.rb | 52 |
2 files changed, 107 insertions, 0 deletions
diff --git a/spec/lib/sidebars/groups/menus/invite_team_members_menu_spec.rb b/spec/lib/sidebars/groups/menus/invite_team_members_menu_spec.rb new file mode 100644 index 00000000000..a79e5182f45 --- /dev/null +++ b/spec/lib/sidebars/groups/menus/invite_team_members_menu_spec.rb @@ -0,0 +1,55 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe Sidebars::Groups::Menus::InviteTeamMembersMenu do + let_it_be(:owner) { create(:user) } + let_it_be(:guest) { create(:user) } + let_it_be(:group) do + build(:group).tap do |g| + g.add_owner(owner) + end + end + + let(:context) { Sidebars::Groups::Context.new(current_user: owner, container: group) } + + subject(:invite_menu) { described_class.new(context) } + + context 'when the group is viewed by an owner of the group' do + describe '#render?' do + it 'renders the Invite team members link' do + expect(invite_menu.render?).to eq(true) + end + + context 'when the group already has at least 2 members' do + before do + group.add_guest(guest) + end + + it 'does not render the link' do + expect(invite_menu.render?).to eq(false) + end + end + end + + describe '#title' do + it 'displays the correct Invite team members text for the link in the side nav' do + expect(invite_menu.title).to eq('Invite members') + end + end + end + + context 'when the group is viewed by a guest user without admin permissions' do + let(:context) { Sidebars::Groups::Context.new(current_user: guest, container: group) } + + before do + group.add_guest(guest) + end + + describe '#render?' do + it 'does not render the link' do + expect(subject.render?).to eq(false) + end + end + end +end diff --git a/spec/lib/sidebars/projects/menus/invite_team_members_menu_spec.rb b/spec/lib/sidebars/projects/menus/invite_team_members_menu_spec.rb new file mode 100644 index 00000000000..df9b260d211 --- /dev/null +++ b/spec/lib/sidebars/projects/menus/invite_team_members_menu_spec.rb @@ -0,0 +1,52 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe Sidebars::Projects::Menus::InviteTeamMembersMenu do + let_it_be(:project) { create(:project) } + let_it_be(:guest) { create(:user) } + + let(:context) { Sidebars::Projects::Context.new(current_user: owner, container: project) } + + subject(:invite_menu) { described_class.new(context) } + + context 'when the project is viewed by an owner of the group' do + let(:owner) { project.owner } + + describe '#render?' do + it 'renders the Invite team members link' do + expect(invite_menu.render?).to eq(true) + end + + context 'when the project already has at least 2 members' do + before do + project.add_guest(guest) + end + + it 'does not render the link' do + expect(invite_menu.render?).to eq(false) + end + end + end + + describe '#title' do + it 'displays the correct Invite team members text for the link in the side nav' do + expect(invite_menu.title).to eq('Invite members') + end + end + end + + context 'when the project is viewed by a guest user without admin permissions' do + let(:context) { Sidebars::Projects::Context.new(current_user: guest, container: project) } + + before do + project.add_guest(guest) + end + + describe '#render?' do + it 'does not render' do + expect(invite_menu.render?).to eq(false) + end + end + end +end |