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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
ebf2dd7a
Commit
ebf2dd7a
authored
Sep 24, 2019
by
Jason Goodman
Committed by
Nick Thomas
Sep 24, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Show last deployment on the environment dashboard
Return last deployment data from backend for each environment
parent
09020aea
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
62 additions
and
6 deletions
+62
-6
ee/app/models/environment_folder.rb
ee/app/models/environment_folder.rb
+1
-1
ee/app/serializers/dashboard_environment_entity.rb
ee/app/serializers/dashboard_environment_entity.rb
+15
-0
ee/spec/controllers/operations_controller_spec.rb
ee/spec/controllers/operations_controller_spec.rb
+34
-0
ee/spec/fixtures/api/schemas/dashboard/operations/environments_list.json
...s/api/schemas/dashboard/operations/environments_list.json
+2
-1
ee/spec/serializers/dashboard_environment_entity_spec.rb
ee/spec/serializers/dashboard_environment_entity_spec.rb
+5
-2
ee/spec/serializers/dashboard_environments_folder_entity_spec.rb
.../serializers/dashboard_environments_folder_entity_spec.rb
+5
-2
No files found.
ee/app/models/environment_folder.rb
View file @
ebf2dd7a
...
...
@@ -15,7 +15,7 @@ class EnvironmentFolder
environments_by_id
=
environments
.
id_in
(
folder_data
.
map
{
|
(
env_id
,
_
)
|
env_id
})
.
includes
(
:project
)
.
includes
(
:project
,
last_deployment:
[
:project
,
deployable: :user
]
)
.
index_by
(
&
:id
)
folders
=
folder_data
.
map
do
|
(
environment_id
,
count
)
|
...
...
ee/app/serializers/dashboard_environment_entity.rb
View file @
ebf2dd7a
...
...
@@ -10,4 +10,19 @@ class DashboardEnvironmentEntity < Grape::Entity
end
expose
:external_url
expose
:last_deployment
,
expose_nil:
false
do
|
environment
|
DeploymentEntity
.
represent
(
environment
.
last_deployment
,
options
.
merge
(
request:
new_request
))
end
private
alias_method
:environment
,
:object
def
new_request
EntityRequest
.
new
(
current_user:
request
.
current_user
,
project:
environment
.
project
)
end
end
ee/spec/controllers/operations_controller_spec.rb
View file @
ebf2dd7a
...
...
@@ -389,6 +389,40 @@ describe OperationsController do
expect
(
project_json
[
'environments'
].
first
[
'within_folder'
]).
to
eq
(
true
)
expect
(
project_json
[
'environments'
].
first
[
'id'
]).
to
eq
(
environment
.
id
)
end
it
'returns the last deployment for an environment'
do
environment
=
create
(
:environment
,
project:
project
)
deployment
=
create
(
:deployment
,
project:
project
,
environment:
environment
,
status: :success
)
get
:environments_list
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
response
).
to
match_response_schema
(
'dashboard/operations/environments_list'
,
dir:
'ee'
)
project_json
=
json_response
[
'projects'
].
first
environment_json
=
project_json
[
'environments'
].
first
last_deployment_json
=
environment_json
[
'last_deployment'
]
expect
(
last_deployment_json
[
'id'
]).
to
eq
(
deployment
.
id
)
end
it
"returns the last deployment's deployable"
do
environment
=
create
(
:environment
,
project:
project
)
ci_build
=
create
(
:ci_build
,
project:
project
)
create
(
:deployment
,
project:
project
,
environment:
environment
,
deployable:
ci_build
,
status: :success
)
get
:environments_list
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
response
).
to
match_response_schema
(
'dashboard/operations/environments_list'
,
dir:
'ee'
)
project_json
=
json_response
[
'projects'
].
first
environment_json
=
project_json
[
'environments'
].
first
deployable_json
=
environment_json
[
'last_deployment'
][
'deployable'
]
expect
(
deployable_json
[
'id'
]).
to
eq
(
ci_build
.
id
)
expect
(
deployable_json
[
'build_path'
]).
to
eq
(
project_job_path
(
project
,
ci_build
))
end
end
end
end
...
...
ee/spec/fixtures/api/schemas/dashboard/operations/environments_list.json
View file @
ebf2dd7a
...
...
@@ -66,7 +66,8 @@
"size"
:
{
"type"
:
"integer"
},
"within_folder"
:
{
"type"
:
"boolean"
},
"external_url"
:
{
"type"
:
"string"
},
"environment_path"
:
{
"type"
:
"string"
}
"environment_path"
:
{
"type"
:
"string"
},
"last_deployment"
:
{
"$ref"
:
"../../../../../../../spec/fixtures/api/schemas/deployment.json"
}
}
}
}
...
...
ee/spec/serializers/dashboard_environment_entity_spec.rb
View file @
ebf2dd7a
...
...
@@ -5,11 +5,14 @@ require 'spec_helper'
describe
DashboardEnvironmentEntity
do
describe
'.as_json'
do
it
'includes environment attributes'
do
user
=
create
(
:user
)
environment
=
create
(
:environment
)
create
(
:deployment
,
project:
environment
.
project
,
environment:
environment
,
status: :success
)
request
=
EntityRequest
.
new
(
current_user:
user
)
result
=
described_class
.
new
(
environment
).
as_json
result
=
described_class
.
new
(
environment
,
request:
request
).
as_json
expect
(
result
.
keys
.
sort
).
to
eq
([
:environment_path
,
:external_url
,
:id
,
:name
])
expect
(
result
.
keys
.
sort
).
to
eq
([
:environment_path
,
:external_url
,
:id
,
:
last_deployment
,
:
name
])
end
end
end
ee/spec/serializers/dashboard_environments_folder_entity_spec.rb
View file @
ebf2dd7a
...
...
@@ -5,13 +5,16 @@ require 'spec_helper'
describe
DashboardEnvironmentsFolderEntity
do
describe
'.as_json'
do
it
'includes folder and environment attributes'
do
user
=
create
(
:user
)
environment
=
create
(
:environment
)
create
(
:deployment
,
project:
environment
.
project
,
environment:
environment
,
status: :success
)
size
=
1
environment_folder
=
EnvironmentFolder
.
new
(
environment
,
size
)
request
=
EntityRequest
.
new
(
current_user:
user
)
result
=
described_class
.
new
(
environment_folder
).
as_json
result
=
described_class
.
new
(
environment_folder
,
request:
request
).
as_json
expect
(
result
.
keys
.
sort
).
to
eq
([
:environment_path
,
:external_url
,
:id
,
:name
,
:size
,
:within_folder
])
expect
(
result
.
keys
.
sort
).
to
eq
([
:environment_path
,
:external_url
,
:id
,
:
last_deployment
,
:
name
,
:size
,
:within_folder
])
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