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
d33e1557
Commit
d33e1557
authored
Sep 05, 2017
by
Bob Van Landuyt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add serializer for group children
parent
376a8c66
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
55 additions
and
0 deletions
+55
-0
app/controllers/groups_controller.rb
app/controllers/groups_controller.rb
+15
-0
app/serializers/group_child_entity.rb
app/serializers/group_child_entity.rb
+20
-0
app/serializers/group_child_serializer.rb
app/serializers/group_child_serializer.rb
+5
-0
spec/serializers/group_child_entity_spec.rb
spec/serializers/group_child_entity_spec.rb
+15
-0
No files found.
app/controllers/groups_controller.rb
View file @
d33e1557
...
@@ -60,7 +60,22 @@ class GroupsController < Groups::ApplicationController
...
@@ -60,7 +60,22 @@ class GroupsController < Groups::ApplicationController
end
end
end
end
def
children
parent
=
Group
.
find_by
(
parent_id:
params
[
:parent_id
])
||
@group
if
parent
.
nil?
||
!
can?
(
current_user
,
:read_group
,
parent
)
render_404
end
@children
=
GroupChildrenFinder
.
new
(
current_user
,
parent_group:
parent
,
params:
params
).
execute
respond_to
do
|
format
|
format
.
json
do
render
json:
GroupChildrenSerializer
.
new
(
current_user:
current_user
)
.
with_pagination
(
request
,
response
)
.
represent
(
@children
)
end
end
end
end
def
activity
def
activity
...
...
app/serializers/group_child_entity.rb
0 → 100644
View file @
d33e1557
class
GroupChildEntity
<
Grape
::
Entity
include
ActionView
::
Helpers
::
NumberHelper
include
RequestAwareEntity
expose
:id
,
:name
,
:description
,
:visibility
,
:full_name
,
:full_path
,
:web_url
,
:created_at
,
:updated_at
,
:star_count
,
:can_edit
,
:type
,
:parent_id
,
:children_count
,
:leave_path
,
:edit_path
,
:number_projects_with_delimiter
,
:number_users_with_delimiter
,
:permissions
,
:star_count
def
type
object
.
class
.
name
.
downcase
end
def
can_edit
return
false
unless
request
.
respond_to?
(
:current_user
)
can?
(
request
.
current_user
,
"edit_{type}"
,
object
)
end
expose
end
app/serializers/group_child_serializer.rb
0 → 100644
View file @
d33e1557
class
GroupChildSerializer
<
BaseSerializer
include
WithPagination
entity
GroupChildEntity
end
spec/serializers/group_child_entity_spec.rb
0 → 100644
View file @
d33e1557
require
'spec_helper'
describe
GroupChildEntity
do
let
(
:request
)
{
double
(
'request'
)
}
let
(
:entity
)
{
described_class
.
new
(
object
,
request:
request
)
}
subject
(
:json
)
{
entity
.
as_json
}
describe
'for a project'
do
let
(
:object
)
{
build_stubbed
(
:project
)
}
it
'has the correct type'
do
expect
(
json
[
:type
]).
to
eq
(
'project'
)
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