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
diff options
context:
space:
mode:
authorBob Van Landuyt <bob@vanlanduyt.co>2017-09-12 20:03:12 +0300
committerBob Van Landuyt <bob@vanlanduyt.co>2017-10-04 23:49:41 +0300
commit3299a970e09ceca7ecabb3d78a5693f58ef79d79 (patch)
tree2e48aab010509078090f304e690f7b9e1f1ae121 /spec/models/concerns
parent3e6dd7d88daaac2dbafc234753942086e0ba0403 (diff)
Handle all cases for merging a hierarchy
The possible cases are: - [Array, Array] - [Array, Hash] - [Array, GroupHierarchy] - [Hash,Hash] - [Hash, GroupHierarchy] - [GroupHierarchy, GroupHierarchy]
Diffstat (limited to 'spec/models/concerns')
-rw-r--r--spec/models/concerns/group_hierarchy_spec.rb11
1 files changed, 11 insertions, 0 deletions
diff --git a/spec/models/concerns/group_hierarchy_spec.rb b/spec/models/concerns/group_hierarchy_spec.rb
index bb02983c776..fe30895f15e 100644
--- a/spec/models/concerns/group_hierarchy_spec.rb
+++ b/spec/models/concerns/group_hierarchy_spec.rb
@@ -62,6 +62,17 @@ describe GroupHierarchy, :nested_groups do
expect(described_class.merge_hierarchies(groups, parent)).to eq(expected_hierarchy)
end
+
+ it 'handles building a tree out of order' do
+ other_subgroup = create(:group, parent: parent)
+ other_subgroup2 = create(:group, parent: parent)
+ other_subsub_group = create(:group, parent: other_subgroup)
+
+ groups = [subsub_group, other_subgroup2, other_subsub_group]
+ expected_hierarchy = { parent => [{ subgroup => subsub_group }, other_subgroup2, { other_subgroup => other_subsub_group }] }
+
+ expect(described_class.merge_hierarchies(groups)).to eq(expected_hierarchy)
+ end
end
end