summaryrefslogtreecommitdiff
path: root/spec/lib/gitlab
diff options
context:
space:
mode:
authorDouwe Maan <douwe@gitlab.com>2017-06-16 17:51:35 +0000
committerDouwe Maan <douwe@gitlab.com>2017-06-16 17:51:35 +0000
commit9b835d10d2c13b55b84461589542b9c77ab90b45 (patch)
tree76074b7c0865006b6df6e007793f6c5cc391f515 /spec/lib/gitlab
parent11b3e54cfe709fdfcbf3d56fa894c4e8c781cef7 (diff)
parentaeaf58609b401b467cbc0c83d3b0a5cb9c04a440 (diff)
downloadgitlab-ce-9b835d10d2c13b55b84461589542b9c77ab90b45.tar.gz
Merge branch 'tc-fix-group-finder-subgrouping' into 'master'
Show private subgroups if member of parent group Closes #32135 See merge request !11764
Diffstat (limited to 'spec/lib/gitlab')
-rw-r--r--spec/lib/gitlab/group_hierarchy_spec.rb24
1 files changed, 24 insertions, 0 deletions
diff --git a/spec/lib/gitlab/group_hierarchy_spec.rb b/spec/lib/gitlab/group_hierarchy_spec.rb
index 5d0ed1522b3..08010c2d0e2 100644
--- a/spec/lib/gitlab/group_hierarchy_spec.rb
+++ b/spec/lib/gitlab/group_hierarchy_spec.rb
@@ -17,6 +17,12 @@ describe Gitlab::GroupHierarchy, :postgresql do
it 'includes all of the ancestors' do
expect(relation).to include(parent, child1)
end
+
+ it 'uses ancestors_base #initialize argument' do
+ relation = described_class.new(Group.where(id: child2.id), Group.none).base_and_ancestors
+
+ expect(relation).to include(parent, child1, child2)
+ end
end
describe '#base_and_descendants' do
@@ -31,6 +37,12 @@ describe Gitlab::GroupHierarchy, :postgresql do
it 'includes all the descendants' do
expect(relation).to include(child1, child2)
end
+
+ it 'uses descendants_base #initialize argument' do
+ relation = described_class.new(Group.none, Group.where(id: parent.id)).base_and_descendants
+
+ expect(relation).to include(parent, child1, child2)
+ end
end
describe '#all_groups' do
@@ -49,5 +61,17 @@ describe Gitlab::GroupHierarchy, :postgresql do
it 'includes the descendants' do
expect(relation).to include(child2)
end
+
+ it 'uses ancestors_base #initialize argument for ancestors' do
+ relation = described_class.new(Group.where(id: child1.id), Group.where(id: Group.maximum(:id).succ)).all_groups
+
+ expect(relation).to include(parent)
+ end
+
+ it 'uses descendants_base #initialize argument for descendants' do
+ relation = described_class.new(Group.where(id: Group.maximum(:id).succ), Group.where(id: child1.id)).all_groups
+
+ expect(relation).to include(child2)
+ end
end
end