summaryrefslogtreecommitdiff
path: root/spec/models
diff options
context:
space:
mode:
authorBob Van Landuyt <bob@vanlanduyt.co>2017-09-19 13:11:09 +0200
committerBob Van Landuyt <bob@vanlanduyt.co>2017-10-04 22:49:41 +0200
commit22aa034427b9392b44d9ecba0a51bb1b6c6616d7 (patch)
tree674a46d4ea73af07ccc3b7f5dd56168d4c5c1997 /spec/models
parentfb7a0f8c335631e1cb8c8f91e135e49528fad70e (diff)
downloadgitlab-ce-22aa034427b9392b44d9ecba0a51bb1b6c6616d7.tar.gz
Rename `GroupHierarchy` to `GroupDescendant`
Diffstat (limited to 'spec/models')
-rw-r--r--spec/models/concerns/group_descendant_spec.rb (renamed from spec/models/concerns/group_hierarchy_spec.rb)29
1 files changed, 28 insertions, 1 deletions
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