Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorBob Van Landuyt <bob@vanlanduyt.co>2017-09-19 14:11:09 +0300
committerBob Van Landuyt <bob@vanlanduyt.co>2017-10-04 23:49:41 +0300
commit22aa034427b9392b44d9ecba0a51bb1b6c6616d7 (patch)
tree674a46d4ea73af07ccc3b7f5dd56168d4c5c1997 /spec
parentfb7a0f8c335631e1cb8c8f91e135e49528fad70e (diff)
Rename `GroupHierarchy` to `GroupDescendant`
Diffstat (limited to 'spec')
-rw-r--r--spec/finders/group_descendants_finder_spec.rb (renamed from spec/finders/group_children_finder_spec.rb)2
-rw-r--r--spec/models/concerns/group_descendant_spec.rb (renamed from spec/models/concerns/group_hierarchy_spec.rb)29
2 files changed, 29 insertions, 2 deletions
diff --git a/spec/finders/group_children_finder_spec.rb b/spec/finders/group_descendants_finder_spec.rb
index 8257e158b06..c1268a486cf 100644
--- a/spec/finders/group_children_finder_spec.rb
+++ b/spec/finders/group_descendants_finder_spec.rb
@@ -1,6 +1,6 @@
require 'spec_helper'
-describe GroupChildrenFinder do
+describe GroupDescendantsFinder do
let(:user) { create(:user) }
let(:group) { create(:group) }
let(:params) { {} }
diff --git a/spec/models/concerns/group_hierarchy_spec.rb b/spec/models/concerns/group_descendant_spec.rb
index fe30895f15e..87eee515cde 100644
--- a/spec/models/concerns/group_hierarchy_spec.rb
+++ b/spec/models/concerns/group_descendant_spec.rb
@@ -1,6 +1,6 @@
require 'spec_helper'
-describe GroupHierarchy, :nested_groups do
+describe GroupDescendant, :nested_groups do
let(:parent) { create(:group) }
let(:subgroup) { create(:group, parent: parent) }
let(:subsub_group) { create(:group, parent: subgroup) }
@@ -141,6 +141,33 @@ describe GroupHierarchy, :nested_groups do
expect(described_class.merge_hierarchies([parent, subgroup])).to eq(expected_hierarchy)
end
+
+ it 'merges complex hierarchies' do
+ project = create(:project, namespace: parent)
+ sub_project = create(:project, namespace: subgroup)
+ subsubsub_group = create(:group, parent: subsub_group)
+ subsub_project = create(:project, namespace: subsub_group)
+ subsubsub_project = create(:project, namespace: subsubsub_group)
+ other_subgroup = create(:group, parent: parent)
+ other_subproject = create(:project, namespace: other_subgroup)
+
+ projects = [project, subsubsub_project, sub_project, other_subproject, subsub_project]
+
+ expected_hierarchy = [
+ project,
+ {
+ subgroup => [
+ { subsub_group => [{ subsubsub_group => subsubsub_project }, subsub_project] },
+ sub_project
+ ]
+ },
+ { other_subgroup => other_subproject }
+ ]
+
+ actual_hierarchy = described_class.merge_hierarchies(projects, parent)
+
+ expect(actual_hierarchy).to eq(expected_hierarchy)
+ end
end
end
end