diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-12-19 14:01:45 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-12-19 14:01:45 +0300 |
commit | 9297025d0b7ddf095eb618dfaaab2ff8f2018d8b (patch) | |
tree | 865198c01d1824a9b098127baa3ab980c9cd2c06 /spec/finders/groups_finder_spec.rb | |
parent | 6372471f43ee03c05a7c1f8b0c6ac6b8a7431dbe (diff) |
Add latest changes from gitlab-org/gitlab@16-7-stable-eev16.7.0-rc42
Diffstat (limited to 'spec/finders/groups_finder_spec.rb')
-rw-r--r-- | spec/finders/groups_finder_spec.rb | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/spec/finders/groups_finder_spec.rb b/spec/finders/groups_finder_spec.rb index f20c03c9658..5d69988a761 100644 --- a/spec/finders/groups_finder_spec.rb +++ b/spec/finders/groups_finder_spec.rb @@ -274,6 +274,38 @@ RSpec.describe GroupsFinder, feature_category: :groups_and_projects do end end + context 'with organization' do + let_it_be(:organization_user) { create(:organization_user) } + let_it_be(:organization) { organization_user.organization } + let_it_be(:user) { organization_user.user } + let_it_be(:public_group) { create(:group, name: 'public-group', organization: organization) } + let_it_be(:outside_organization_group) { create(:group) } + let_it_be(:private_group) { create(:group, :private, name: 'private-group', organization: organization) } + let_it_be(:no_access_group_in_org) { create(:group, :private, name: 'no-access', organization: organization) } + + let(:current_user) { user } + let(:params) { { organization: organization } } + let(:finder) { described_class.new(current_user, params) } + + subject(:result) { finder.execute.to_a } + + before_all do + private_group.add_developer(user) + public_group.add_developer(user) + outside_organization_group.add_developer(user) + end + + context 'when user is only authorized to read the public group' do + let(:current_user) { create(:user) } + + it { is_expected.to contain_exactly(public_group) } + end + + it 'return all groups inside the organization' do + expect(result).to contain_exactly(public_group, private_group) + end + end + context 'with include_ancestors' do let_it_be(:user) { create(:user) } |