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
Boxiang Sun
gitlab-ce
Commits
3e6dd7d8
Commit
3e6dd7d8
authored
Sep 12, 2017
by
Bob Van Landuyt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use same response-body in groups-dashboard as we do for group-home
parent
960559aa
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
52 additions
and
7 deletions
+52
-7
app/controllers/dashboard/groups_controller.rb
app/controllers/dashboard/groups_controller.rb
+4
-5
app/serializers/group_child_serializer.rb
app/serializers/group_child_serializer.rb
+3
-2
spec/controllers/dashboard/groups_controller_spec.rb
spec/controllers/dashboard/groups_controller_spec.rb
+29
-0
spec/serializers/group_child_serializer_spec.rb
spec/serializers/group_child_serializer_spec.rb
+16
-0
No files found.
app/controllers/dashboard/groups_controller.rb
View file @
3e6dd7d8
...
@@ -15,7 +15,7 @@ class Dashboard::GroupsController < Dashboard::ApplicationController
...
@@ -15,7 +15,7 @@ class Dashboard::GroupsController < Dashboard::ApplicationController
current_user
.
groups
current_user
.
groups
end
end
@groups
=
@groups
.
search
(
params
[
:filter
_groups
])
if
params
[
:filter_groups
].
present?
@groups
=
@groups
.
search
(
params
[
:filter
])
if
params
[
:filter
].
present?
@groups
=
@groups
.
includes
(
:route
)
@groups
=
@groups
.
includes
(
:route
)
@groups
=
@groups
.
sort
(
@sort
)
@groups
=
@groups
.
sort
(
@sort
)
@groups
=
@groups
.
page
(
params
[
:page
])
@groups
=
@groups
.
page
(
params
[
:page
])
...
@@ -23,10 +23,9 @@ class Dashboard::GroupsController < Dashboard::ApplicationController
...
@@ -23,10 +23,9 @@ class Dashboard::GroupsController < Dashboard::ApplicationController
respond_to
do
|
format
|
respond_to
do
|
format
|
format
.
html
format
.
html
format
.
json
do
format
.
json
do
render
json:
GroupSerializer
serializer
=
GroupChildSerializer
.
new
(
current_user:
current_user
)
.
new
(
current_user:
@current_user
)
.
with_pagination
(
request
,
response
)
.
with_pagination
(
request
,
response
)
.
represent
(
@groups
)
render
json:
serializer
.
represent
(
@groups
)
end
end
end
end
end
end
...
...
app/serializers/group_child_serializer.rb
View file @
3e6dd7d8
...
@@ -5,13 +5,14 @@ class GroupChildSerializer < BaseSerializer
...
@@ -5,13 +5,14 @@ class GroupChildSerializer < BaseSerializer
entity
GroupChildEntity
entity
GroupChildEntity
def
expand_hierarchy
(
hierarchy_root
)
def
expand_hierarchy
(
hierarchy_root
=
nil
)
@hierarchy_root
=
hierarchy_root
@hierarchy_root
=
hierarchy_root
@expand_hierarchy
=
true
self
self
end
end
def
represent
(
resource
,
opts
=
{},
entity_class
=
nil
)
def
represent
(
resource
,
opts
=
{},
entity_class
=
nil
)
if
hierarchy_root
.
present?
if
@expand_hierarchy
represent_hierarchies
(
resource
,
opts
)
represent_hierarchies
(
resource
,
opts
)
else
else
super
(
resource
,
opts
)
super
(
resource
,
opts
)
...
...
spec/controllers/dashboard/groups_controller_spec.rb
0 → 100644
View file @
3e6dd7d8
require
'spec_helper'
describe
Dashboard
::
GroupsController
do
let
(
:group
)
{
create
(
:group
,
:public
)
}
let
(
:user
)
{
create
(
:user
)
}
before
do
group
.
add_owner
(
user
)
sign_in
(
user
)
end
describe
'GET #index'
do
it
'shows child groups as json'
do
get
:index
,
format: :json
expect
(
json_response
.
first
[
'id'
]).
to
eq
(
group
.
id
)
end
it
'filters groups'
do
other_group
=
create
(
:group
,
name:
'filter'
)
other_group
.
add_owner
(
user
)
get
:index
,
filter:
'filt'
,
format: :json
all_ids
=
json_response
.
map
{
|
group_json
|
group_json
[
'id'
]
}
expect
(
all_ids
).
to
contain_exactly
(
other_group
.
id
)
end
end
end
spec/serializers/group_child_serializer_spec.rb
View file @
3e6dd7d8
...
@@ -49,6 +49,22 @@ describe GroupChildSerializer do
...
@@ -49,6 +49,22 @@ describe GroupChildSerializer do
expect
(
subgroup1_json
[
:id
]).
to
eq
(
subgroup1
.
id
)
expect
(
subgroup1_json
[
:id
]).
to
eq
(
subgroup1
.
id
)
expect
(
subsub_group1_json
[
:id
]).
to
eq
(
subsub_group1
.
id
)
expect
(
subsub_group1_json
[
:id
]).
to
eq
(
subsub_group1
.
id
)
end
end
context
'without a specified parent'
do
subject
(
:serializer
)
do
described_class
.
new
(
current_user:
user
).
expand_hierarchy
end
it
'can render a tree'
do
subgroup
=
create
(
:group
,
parent:
parent
)
json
=
serializer
.
represent
([
subgroup
])
parent_json
=
json
.
first
expect
(
parent_json
[
:id
]).
to
eq
(
parent
.
id
)
expect
(
parent_json
[
:children
].
first
[
:id
]).
to
eq
(
subgroup
.
id
)
end
end
end
end
context
'for projects'
do
context
'for projects'
do
...
...
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