summaryrefslogtreecommitdiff
path: root/spec/finders/groups_finder_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/finders/groups_finder_spec.rb')
-rw-r--r--spec/finders/groups_finder_spec.rb36
1 files changed, 34 insertions, 2 deletions
diff --git a/spec/finders/groups_finder_spec.rb b/spec/finders/groups_finder_spec.rb
index abc470788e1..dbbdbbfe4ee 100644
--- a/spec/finders/groups_finder_spec.rb
+++ b/spec/finders/groups_finder_spec.rb
@@ -57,11 +57,43 @@ describe GroupsFinder do
is_expected.to contain_exactly(parent_group, public_subgroup, internal_subgroup)
end
+ context 'subgroups multiple levels deep' do
+ let(:subsub_group) { create(:group, parent: private_subgroup) }
+
+ it 'can return subgroups multiple levels deep' do
+ is_expected.to include(subsub_group)
+ end
+
+ context 'when a parent is given and children should be included' do
+ let(:other_parent) { create(:group, :public) }
+
+ subject { described_class.new(user, parent: parent_group, all_children_for_parent: true).execute }
+
+ it 'includes children multiple levels deep' do
+ is_expected.to include(subsub_group)
+ end
+
+ it 'excludes groups with a different ancestor' do
+ is_expected.not_to include(other_parent)
+ end
+ end
+ end
+
context 'being member' do
- it 'returns parent, public subgroups, internal subgroups, and private subgroups user is member of' do
+ let(:other_public_group) { create(:group, :public) }
+
+ before do
private_subgroup.add_guest(user)
+ end
+
+ it 'returns parent, public subgroups, internal subgroups, and private subgroups user is member of' do
+ is_expected.to contain_exactly(other_public_group, parent_group, public_subgroup, internal_subgroup, private_subgroup)
+ end
+
+ it 'allows excluding public groups' do
+ result = described_class.new(user, all_available: false).execute
- is_expected.to contain_exactly(parent_group, public_subgroup, internal_subgroup, private_subgroup)
+ expect(result).to contain_exactly(parent_group, private_subgroup)
end
end