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
de24df98
Commit
de24df98
authored
May 06, 2019
by
Grzegorz Bizon
Committed by
Filipa Lacerda
May 24, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Do not serialize deployment details for build details page
parent
412a3857
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
48 additions
and
12 deletions
+48
-12
app/serializers/build_details_entity.rb
app/serializers/build_details_entity.rb
+1
-1
app/serializers/deployment_entity.rb
app/serializers/deployment_entity.rb
+9
-5
spec/controllers/projects/jobs_controller_spec.rb
spec/controllers/projects/jobs_controller_spec.rb
+4
-4
spec/serializers/build_details_entity_spec.rb
spec/serializers/build_details_entity_spec.rb
+2
-2
spec/serializers/deployment_entity_spec.rb
spec/serializers/deployment_entity_spec.rb
+32
-0
No files found.
app/serializers/build_details_entity.rb
View file @
de24df98
...
@@ -14,7 +14,7 @@ class BuildDetailsEntity < JobEntity
...
@@ -14,7 +14,7 @@ class BuildDetailsEntity < JobEntity
expose
:deployment_status
,
if:
->
(
*
)
{
build
.
starts_environment?
}
do
expose
:deployment_status
,
if:
->
(
*
)
{
build
.
starts_environment?
}
do
expose
:deployment_status
,
as: :status
expose
:deployment_status
,
as: :status
expose
:persisted_environment
,
as: :environment
do
|
build
,
options
|
expose
:persisted_environment
,
as: :environment
do
|
build
,
options
|
options
.
merge
(
except:
[{
last_deployment:
[
:commit
]
}]
).
yield_self
do
|
opts
|
options
.
merge
(
deployment_details:
false
).
yield_self
do
|
opts
|
EnvironmentEntity
.
represent
(
build
.
persisted_environment
,
opts
)
EnvironmentEntity
.
represent
(
build
.
persisted_environment
,
opts
)
end
end
end
end
...
...
app/serializers/deployment_entity.rb
View file @
de24df98
...
@@ -20,15 +20,19 @@ class DeploymentEntity < Grape::Entity
...
@@ -20,15 +20,19 @@ class DeploymentEntity < Grape::Entity
expose
:created_at
expose
:created_at
expose
:tag
expose
:tag
expose
:last?
expose
:last?
expose
:user
,
using:
UserEntity
expose
:user
,
using:
UserEntity
expose
:commit
,
using:
CommitEntity
expose
:deployable
,
using:
JobEntity
expose
:commit
,
using:
CommitEntity
,
if:
->
(
*
)
{
include_details?
}
expose
:manual_actions
,
using:
JobEntity
,
if:
->
(
*
)
{
can_create_deployment?
}
expose
:deployable
,
using:
JobEntity
,
if:
->
(
*
)
{
include_details?
}
expose
:scheduled_actions
,
using:
JobEntity
,
if:
->
(
*
)
{
can_create_deployment?
}
expose
:manual_actions
,
using:
JobEntity
,
if:
->
(
*
)
{
include_details?
&&
can_create_deployment?
}
expose
:scheduled_actions
,
using:
JobEntity
,
if:
->
(
*
)
{
include_details?
&&
can_create_deployment?
}
private
private
def
include_details?
options
.
fetch
(
:deployment_details
,
true
)
end
def
can_create_deployment?
def
can_create_deployment?
can?
(
request
.
current_user
,
:create_deployment
,
request
.
project
)
can?
(
request
.
current_user
,
:create_deployment
,
request
.
project
)
end
end
...
...
spec/controllers/projects/jobs_controller_spec.rb
View file @
de24df98
...
@@ -253,14 +253,14 @@ describe Projects::JobsController, :clean_gitlab_redis_shared_state do
...
@@ -253,14 +253,14 @@ describe Projects::JobsController, :clean_gitlab_redis_shared_state do
end
end
context
'with deployment'
do
context
'with deployment'
do
before
do
create
(
:deployment
,
:success
,
environment:
environment
,
project:
project
)
end
let
(
:merge_request
)
{
create
(
:merge_request
,
source_project:
project
)
}
let
(
:merge_request
)
{
create
(
:merge_request
,
source_project:
project
)
}
let
(
:environment
)
{
create
(
:environment
,
project:
project
,
name:
'staging'
,
state: :available
)
}
let
(
:environment
)
{
create
(
:environment
,
project:
project
,
name:
'staging'
,
state: :available
)
}
let
(
:job
)
{
create
(
:ci_build
,
:running
,
environment:
environment
.
name
,
pipeline:
pipeline
)
}
let
(
:job
)
{
create
(
:ci_build
,
:running
,
environment:
environment
.
name
,
pipeline:
pipeline
)
}
before
do
create
(
:deployment
,
:success
,
environment:
environment
,
project:
project
)
end
it
'exposes the deployment information'
do
it
'exposes the deployment information'
do
get_show_json
get_show_json
...
...
spec/serializers/build_details_entity_spec.rb
View file @
de24df98
...
@@ -138,11 +138,11 @@ describe BuildDetailsEntity do
...
@@ -138,11 +138,11 @@ describe BuildDetailsEntity do
allow
(
request
).
to
receive
(
:project
).
and_return
(
project
)
allow
(
request
).
to
receive
(
:project
).
and_return
(
project
)
end
end
it
'does not serialize latest deployment commit'
do
it
'does not serialize latest deployment commit
and associated builds
'
do
response
=
subject
.
with_indifferent_access
response
=
subject
.
with_indifferent_access
response
.
dig
(
:deployment_status
,
:environment
,
:last_deployment
).
tap
do
|
deployment
|
response
.
dig
(
:deployment_status
,
:environment
,
:last_deployment
).
tap
do
|
deployment
|
expect
(
deployment
).
not_to
include
(
:commit
)
expect
(
deployment
).
not_to
include
(
:commit
,
:deployable
,
:manual_actions
,
:scheduled_actions
)
end
end
end
end
end
end
...
...
spec/serializers/deployment_entity_spec.rb
View file @
de24df98
...
@@ -10,6 +10,7 @@ describe DeploymentEntity do
...
@@ -10,6 +10,7 @@ describe DeploymentEntity do
let
(
:build
)
{
create
(
:ci_build
,
:manual
,
pipeline:
pipeline
)
}
let
(
:build
)
{
create
(
:ci_build
,
:manual
,
pipeline:
pipeline
)
}
let
(
:pipeline
)
{
create
(
:ci_pipeline
,
project:
project
,
user:
user
)
}
let
(
:pipeline
)
{
create
(
:ci_pipeline
,
project:
project
,
user:
user
)
}
let
(
:entity
)
{
described_class
.
new
(
deployment
,
request:
request
)
}
let
(
:entity
)
{
described_class
.
new
(
deployment
,
request:
request
)
}
subject
{
entity
.
as_json
}
subject
{
entity
.
as_json
}
before
do
before
do
...
@@ -47,6 +48,16 @@ describe DeploymentEntity do
...
@@ -47,6 +48,16 @@ describe DeploymentEntity do
expect
(
subject
[
:manual_actions
]).
not_to
be_present
expect
(
subject
[
:manual_actions
]).
not_to
be_present
end
end
end
end
context
'when deployment details serialization was disabled'
do
let
(
:entity
)
do
described_class
.
new
(
deployment
,
request:
request
,
deployment_details:
false
)
end
it
'does not serialize manual actions details'
do
expect
(
subject
.
with_indifferent_access
).
not_to
include
(
:manual_actions
)
end
end
end
end
describe
'scheduled_actions'
do
describe
'scheduled_actions'
do
...
@@ -69,5 +80,26 @@ describe DeploymentEntity do
...
@@ -69,5 +80,26 @@ describe DeploymentEntity do
expect
(
subject
[
:scheduled_actions
]).
to
be_empty
expect
(
subject
[
:scheduled_actions
]).
to
be_empty
end
end
end
end
context
'when deployment details serialization was disabled'
do
let
(
:entity
)
do
described_class
.
new
(
deployment
,
request:
request
,
deployment_details:
false
)
end
it
'does not serialize scheduled actions details'
do
expect
(
subject
.
with_indifferent_access
).
not_to
include
(
:scheduled_actions
)
end
end
end
context
'when deployment details serialization was disabled'
do
let
(
:entity
)
do
described_class
.
new
(
deployment
,
request:
request
,
deployment_details:
false
)
end
it
'does not serialize deployment details'
do
expect
(
subject
.
with_indifferent_access
)
.
not_to
include
(
:commit
,
:deployable
,
:manual_actions
,
:scheduled_actions
)
end
end
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