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
73203873
Commit
73203873
authored
Mar 28, 2017
by
Pawel Chojnacki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use DeploymentSerializer to create deployment json
parent
601f50c6
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
12 additions
and
6 deletions
+12
-6
app/controllers/projects/deployments_controller.rb
app/controllers/projects/deployments_controller.rb
+2
-1
app/serializers/deployment_entity.rb
app/serializers/deployment_entity.rb
+1
-0
app/serializers/deployment_serializer.rb
app/serializers/deployment_serializer.rb
+3
-0
spec/controllers/projects/deployments_controller_spec.rb
spec/controllers/projects/deployments_controller_spec.rb
+2
-5
spec/serializers/deployment_entity_spec.rb
spec/serializers/deployment_entity_spec.rb
+4
-0
No files found.
app/controllers/projects/deployments_controller.rb
View file @
73203873
...
...
@@ -2,8 +2,9 @@ class Projects::DeploymentsController < Projects::ApplicationController
before_action
:authorize_read_deployment!
def
index
serializer
=
DeploymentSerializer
.
new
(
user:
@current_user
)
deployments
=
environment
.
deployments
.
where
(
'created_at > ?'
,
8
.
hours
.
ago
)
.
map
{
|
d
|
d
.
slice
(
:id
,
:iid
,
:created_at
,
:sha
,
:ref
,
:tag
)
}
.
map
{
|
d
|
serializer
.
represent
(
d
)
}
render
json:
{
deployments:
deployments
}
end
...
...
app/serializers/deployment_entity.rb
View file @
73203873
...
...
@@ -18,6 +18,7 @@ class DeploymentEntity < Grape::Entity
end
end
expose
:created_at
expose
:tag
expose
:last?
expose
:user
,
using:
UserEntity
...
...
app/serializers/deployment_serializer.rb
0 → 100644
View file @
73203873
class
DeploymentSerializer
<
BaseSerializer
entity
DeploymentEntity
end
spec/controllers/projects/deployments_controller_spec.rb
View file @
73203873
...
...
@@ -28,19 +28,16 @@ describe Projects::DeploymentsController do
end
it
'returns a list with deployments information'
do
deployment
=
create
(
:deployment
,
environment:
environment
)
create
(
:deployment
,
environment:
environment
)
get
:index
,
environment_params
expect
(
response
).
to
be_ok
deployments
=
json_response
[
'deployments'
]
deployment_info
=
deployments
.
first
.
with_indifferent_access
created_at
=
deployment_info
.
delete
(
:created_at
).
to_time
.
utc
expect
(
deployments
.
count
).
to
eq
(
1
)
expect
(
deployment_info
).
to
include
(
:id
,
:iid
,
:sha
,
:ref
,
:tag
)
expect
(
deployment
).
to
have_attributes
(
deployment_info
)
expect
(
deployment
.
created_at
).
to
be_within
(
1
.
second
).
of
(
created_at
)
expect
(
deployment_info
).
to
include
(
:id
,
:iid
,
:sha
,
:ref
,
:tag
,
:created_at
)
end
end
...
...
spec/serializers/deployment_entity_spec.rb
View file @
73203873
...
...
@@ -24,4 +24,8 @@ describe DeploymentEntity 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