BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
ea4e17e2
Commit
ea4e17e2
authored
Sep 14, 2017
by
Bob Van Landuyt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Search subgroups on dashboard and explore views
parent
3a4dc55f
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
31 additions
and
5 deletions
+31
-5
group_tree.rb
app/controllers/concerns/group_tree.rb
+8
-3
group_tree_spec.rb
spec/controllers/concerns/group_tree_spec.rb
+23
-1
groups_controller_spec.rb
spec/controllers/explore/groups_controller_spec.rb
+0
-1
No files found.
app/controllers/concerns/group_tree.rb
View file @
ea4e17e2
module
GroupTree
def
render_group_tree
(
groups
)
# Only show root groups if no parent-id is given
@groups
=
groups
.
where
(
parent_id:
params
[
:parent_id
])
@groups
=
@groups
.
search
(
params
[
:filter
])
if
params
[
:filter
].
present?
if
params
[
:filter
].
present?
@groups
=
Gitlab
::
GroupHierarchy
.
new
(
groups
).
all_groups
@groups
=
@groups
.
search
(
params
[
:filter
])
else
# Only show root groups if no parent-id is given
@groups
=
groups
.
where
(
parent_id:
params
[
:parent_id
])
end
@groups
=
@groups
.
includes
(
:route
)
@groups
=
@groups
.
sort
(
@sort
=
params
[
:sort
])
@groups
=
@groups
.
page
(
params
[
:page
])
...
...
@@ -12,6 +16,7 @@ module GroupTree
format
.
json
do
serializer
=
GroupChildSerializer
.
new
(
current_user:
current_user
)
.
with_pagination
(
request
,
response
)
serializer
.
expand_hierarchy
if
params
[
:filter
].
present?
render
json:
serializer
.
represent
(
@groups
)
end
end
...
...
spec/controllers/concerns/group_tree_spec.rb
View file @
ea4e17e2
...
...
@@ -5,7 +5,8 @@ describe GroupTree do
let
(
:user
)
{
create
(
:user
)
}
controller
(
ApplicationController
)
do
include
GroupTree
# rubocop:disable Rspec/DescribedClass
# `described_class` is not available in this context
include
GroupTree
# rubocop:disable RSpec/DescribedClass
def
index
render_group_tree
Group
.
all
...
...
@@ -43,6 +44,14 @@ describe GroupTree do
expect
(
assigns
(
:groups
)).
to
contain_exactly
(
subgroup
)
end
it
'allows filtering for subgroups'
do
subgroup
=
create
(
:group
,
:public
,
parent:
group
,
name:
'filter'
)
get
:index
,
filter:
'filt'
,
format: :json
expect
(
assigns
(
:groups
)).
to
contain_exactly
(
subgroup
)
end
end
context
'json content'
do
...
...
@@ -51,6 +60,19 @@ describe GroupTree do
expect
(
json_response
.
first
[
'id'
]).
to
eq
(
group
.
id
)
end
context
'nested groups'
,
:nested_groups
do
it
'expands the tree when filtering'
do
subgroup
=
create
(
:group
,
:public
,
parent:
group
,
name:
'filter'
)
get
:index
,
filter:
'filt'
,
format: :json
children_response
=
json_response
.
first
[
'children'
]
expect
(
json_response
.
first
[
'id'
]).
to
eq
(
group
.
id
)
expect
(
children_response
.
first
[
'id'
]).
to
eq
(
subgroup
.
id
)
end
end
end
end
end
spec/controllers/explore/groups_controller_spec.rb
View file @
ea4e17e2
...
...
@@ -20,5 +20,4 @@ describe Explore::GroupsController do
expect
(
assigns
(
:groups
)).
to
contain_exactly
(
member_of_group
,
public_group
)
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