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
Jérome Perrin
gitlab-ce
Commits
4c8942f9
Commit
4c8942f9
authored
Sep 13, 2017
by
Bob Van Landuyt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Replace `full_path`, `path` & `web_url` with a single `relative_path`
parent
1fb49b87
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
5 deletions
+11
-5
app/serializers/group_child_entity.rb
app/serializers/group_child_entity.rb
+9
-1
spec/serializers/group_child_entity_spec.rb
spec/serializers/group_child_entity_spec.rb
+2
-4
No files found.
app/serializers/group_child_entity.rb
View file @
4c8942f9
...
@@ -2,7 +2,7 @@ class GroupChildEntity < Grape::Entity
...
@@ -2,7 +2,7 @@ class GroupChildEntity < Grape::Entity
include
ActionView
::
Helpers
::
NumberHelper
include
ActionView
::
Helpers
::
NumberHelper
include
RequestAwareEntity
include
RequestAwareEntity
expose
:id
,
:name
,
:
path
,
:description
,
:visibility
,
:full_name
,
:full_path
,
:web_url
,
expose
:id
,
:name
,
:
description
,
:visibility
,
:full_name
,
:relative_path
,
:created_at
,
:updated_at
,
:can_edit
,
:type
,
:avatar_url
,
:permission
,
:edit_path
:created_at
,
:updated_at
,
:can_edit
,
:type
,
:avatar_url
,
:permission
,
:edit_path
def
project?
def
project?
...
@@ -31,6 +31,14 @@ class GroupChildEntity < Grape::Entity
...
@@ -31,6 +31,14 @@ class GroupChildEntity < Grape::Entity
end
end
end
end
def
relative_path
if
project?
project_path
(
object
)
else
group_path
(
object
)
end
end
def
permission
def
permission
return
unless
request
&
.
current_user
return
unless
request
&
.
current_user
...
...
spec/serializers/group_child_entity_spec.rb
View file @
4c8942f9
...
@@ -16,19 +16,17 @@ describe GroupChildEntity do
...
@@ -16,19 +16,17 @@ describe GroupChildEntity do
end
end
%w[id
%w[id
path
full_name
full_name
full_path
avatar_url
avatar_url
name
name
description
description
web_url
visibility
visibility
type
type
can_edit
can_edit
visibility
visibility
edit_path
edit_path
permission]
.
each
do
|
attribute
|
permission
relative_path]
.
each
do
|
attribute
|
it
"includes
#{
attribute
}
"
do
it
"includes
#{
attribute
}
"
do
expect
(
json
[
attribute
.
to_sym
]).
to
be_present
expect
(
json
[
attribute
.
to_sym
]).
to
be_present
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