diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-10-05 16:54:15 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-10-05 16:54:15 +0300 |
commit | be834a25982746ffd85252ff502df42bb88cb9d5 (patch) | |
tree | b4d6a8ba0931e12fac08f05abea33a3b8ec2c8a2 /spec/finders/groups_finder_spec.rb | |
parent | ee925a3597f27e92f83a50937a64068109675b3d (diff) |
Add latest changes from gitlab-org/gitlab@13-5-stable-eev13.5.0-rc32
Diffstat (limited to 'spec/finders/groups_finder_spec.rb')
-rw-r--r-- | spec/finders/groups_finder_spec.rb | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/spec/finders/groups_finder_spec.rb b/spec/finders/groups_finder_spec.rb index 48e4c5dadc9..c9e9328794e 100644 --- a/spec/finders/groups_finder_spec.rb +++ b/spec/finders/groups_finder_spec.rb @@ -161,5 +161,61 @@ RSpec.describe GroupsFinder do end end end + + context 'with include parent group descendants' do + let_it_be(:user) { create(:user) } + let_it_be(:parent_group) { create(:group, :public) } + let_it_be(:public_subgroup) { create(:group, :public, parent: parent_group) } + let_it_be(:internal_sub_subgroup) { create(:group, :internal, parent: public_subgroup) } + let_it_be(:private_sub_subgroup) { create(:group, :private, parent: public_subgroup) } + let_it_be(:public_sub_subgroup) { create(:group, :public, parent: public_subgroup) } + let(:params) { { include_parent_descendants: true, parent: parent_group } } + + context 'with nil parent' do + it 'returns all accessible groups' do + params[:parent] = nil + expect(described_class.new(user, params).execute).to contain_exactly( + parent_group, + public_subgroup, + internal_sub_subgroup, + public_sub_subgroup + ) + end + end + + context 'without a user' do + it 'only returns the group public descendants' do + expect(described_class.new(nil, params).execute).to contain_exactly( + public_subgroup, + public_sub_subgroup + ) + end + end + + context 'when a user is present' do + it 'returns the group public and internal descendants' do + expect(described_class.new(user, params).execute).to contain_exactly( + public_subgroup, + public_sub_subgroup, + internal_sub_subgroup + ) + end + end + + context 'when a parent group member is present' do + before do + parent_group.add_developer(user) + end + + it 'returns all group descendants' do + expect(described_class.new(user, params).execute).to contain_exactly( + public_subgroup, + public_sub_subgroup, + internal_sub_subgroup, + private_sub_subgroup + ) + end + end + end end end |