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
33f7c40f
Commit
33f7c40f
authored
Apr 24, 2017
by
Pawel Chojnacki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
use represent_concise instead of separate entity
parent
e057ad97
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
18 additions
and
42 deletions
+18
-42
app/controllers/projects/deployments_controller.rb
app/controllers/projects/deployments_controller.rb
+1
-1
app/serializers/deployment_entity.rb
app/serializers/deployment_entity.rb
+12
-0
app/serializers/deployment_entity_detailed.rb
app/serializers/deployment_entity_detailed.rb
+0
-15
app/serializers/deployment_serializer.rb
app/serializers/deployment_serializer.rb
+5
-0
spec/serializers/deployment_entity_detailed_spec.rb
spec/serializers/deployment_entity_detailed_spec.rb
+0
-26
No files found.
app/controllers/projects/deployments_controller.rb
View file @
33f7c40f
...
...
@@ -7,7 +7,7 @@ class Projects::DeploymentsController < Projects::ApplicationController
deployments
=
deployments
.
where
(
'created_at > ?'
,
params
[
:after
].
to_time
)
if
params
[
:after
]
&
.
to_time
render
json:
{
deployments:
DeploymentSerializer
.
new
(
user:
@current_user
,
project:
project
)
.
represent
(
deployments
)
}
.
represent
_concise
(
deployments
)
}
end
private
...
...
app/serializers/deployment_entity.rb
View file @
33f7c40f
...
...
@@ -9,9 +9,21 @@ class DeploymentEntity < Grape::Entity
expose
:name
do
|
deployment
|
deployment
.
ref
end
expose
:ref_path
do
|
deployment
|
namespace_project_tree_path
(
deployment
.
project
.
namespace
,
deployment
.
project
,
id:
deployment
.
ref
)
end
end
expose
:created_at
expose
:tag
expose
:last?
expose
:user
,
using:
UserEntity
expose
:commit
,
using:
CommitEntity
expose
:deployable
,
using:
BuildEntity
expose
:manual_actions
,
using:
BuildEntity
end
app/serializers/deployment_entity_detailed.rb
deleted
100644 → 0
View file @
e057ad97
class
DeploymentEntityDetailed
<
DeploymentEntity
expose
:ref
do
expose
:ref_path
do
|
deployment
|
namespace_project_tree_path
(
deployment
.
project
.
namespace
,
deployment
.
project
,
id:
deployment
.
ref
)
end
end
expose
:user
,
using:
UserEntity
expose
:commit
,
using:
CommitEntity
expose
:deployable
,
using:
BuildEntity
expose
:manual_actions
,
using:
BuildEntity
end
app/serializers/deployment_serializer.rb
View file @
33f7c40f
class
DeploymentSerializer
<
BaseSerializer
entity
DeploymentEntity
def
represent_concise
(
resource
,
opts
=
{})
opts
[
:only
]
=
[
:iid
,
:id
,
:sha
,
:created_at
,
:tag
,
:last?
,
:id
,
ref:
[
:name
]]
represent
(
resource
,
opts
)
end
end
spec/serializers/deployment_entity_detailed_spec.rb
deleted
100644 → 0
View file @
e057ad97
require
'spec_helper'
describe
DeploymentEntityDetailed
do
let
(
:user
)
{
create
(
:user
)
}
let
(
:request
)
{
double
(
'request'
)
}
let
(
:deployment
)
{
create
(
:deployment
)
}
let
(
:entity
)
{
described_class
.
new
(
deployment
,
request:
request
)
}
subject
{
entity
.
as_json
}
before
do
allow
(
request
).
to
receive
(
:user
).
and_return
(
user
)
end
it
'exposes internal deployment id'
do
expect
(
subject
).
to
include
(
:iid
)
end
it
'exposes nested information about branch'
do
expect
(
subject
[
:ref
][
:name
]).
to
eq
'master'
expect
(
subject
[
:ref
][
:ref_path
]).
not_to
be_empty
end
it
'exposes creation date'
do
expect
(
subject
).
to
include
(
:created_at
)
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