Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Léo-Paul Géneau
gitlab-ce
Commits
bb5187bb
Commit
bb5187bb
authored
Sep 10, 2017
by
Bob Van Landuyt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Handle case where 2 matches in the same tree are found
parent
8f6dac49
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
14 additions
and
5 deletions
+14
-5
app/finders/group_children_finder.rb
app/finders/group_children_finder.rb
+2
-4
app/models/concerns/group_hierarchy.rb
app/models/concerns/group_hierarchy.rb
+6
-1
spec/models/concerns/group_hierarchy_spec.rb
spec/models/concerns/group_hierarchy_spec.rb
+6
-0
No files found.
app/finders/group_children_finder.rb
View file @
bb5187bb
...
...
@@ -52,7 +52,7 @@ class GroupChildrenFinder
end
def
subgroups_matching_filter
all_subgroups
.
search
(
params
[
:filter
])
.
include
(
:parent
)
all_subgroups
.
search
(
params
[
:filter
])
end
def
subgroups
...
...
@@ -64,7 +64,7 @@ class GroupChildrenFinder
else
base_groups
end
groups
=
groups
.
includes
(
:route
).
includes
(
:children
)
groups
=
groups
groups
.
sort
(
params
[
:sort
])
end
...
...
@@ -75,7 +75,6 @@ class GroupChildrenFinder
def
projects_matching_filter
ProjectsFinder
.
new
(
current_user:
current_user
).
execute
.
search
(
params
[
:filter
])
.
include
(
:namespace
)
.
where
(
namespace:
all_subgroups
)
end
...
...
@@ -87,7 +86,6 @@ class GroupChildrenFinder
else
base_projects
end
projects
=
projects
.
includes
(
:route
)
projects
.
sort
(
params
[
:sort
])
end
end
app/models/concerns/group_hierarchy.rb
View file @
bb5187bb
...
...
@@ -62,7 +62,12 @@ module GroupHierarchy
# If both of them are hashes, we can deep_merge with the same logic
elsif
first_child
.
is_a?
(
Hash
)
&&
second_child
.
is_a?
(
Hash
)
first_child
.
deep_merge
(
second_child
)
{
|
key
,
first
,
second
|
merge_values
(
first
,
second
)
}
# One of them is a root node, we just need to put them next to eachother in an array
# If only one of them is a hash, we can check if the other child is already
# included, we don't need to do anything when it is.
elsif
first_child
.
is_a?
(
Hash
)
&&
first_child
.
keys
.
include?
(
second_child
)
first_child
elsif
second_child
.
is_a?
(
Hash
)
&&
second_child
.
keys
.
include?
(
first_child
)
second_child
else
Array
.
wrap
(
first_child
)
+
Array
.
wrap
(
second_child
)
end
...
...
spec/models/concerns/group_hierarchy_spec.rb
View file @
bb5187bb
...
...
@@ -124,6 +124,12 @@ describe GroupHierarchy, :nested_groups do
expect
(
described_class
.
merge_hierarchies
(
elements
,
parent
)).
to
eq
(
expected_hierarchy
)
end
it
'merges to elements in the same hierarchy'
do
expected_hierarchy
=
{
parent
=>
subgroup
}
expect
(
described_class
.
merge_hierarchies
([
parent
,
subgroup
])).
to
eq
(
expected_hierarchy
)
end
end
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment