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
88b03bb5
Commit
88b03bb5
authored
Oct 10, 2016
by
Z.J. van de Weg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rename method in test
parent
58368fbc
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
31 additions
and
21 deletions
+31
-21
app/controllers/projects/merge_requests_controller.rb
app/controllers/projects/merge_requests_controller.rb
+23
-18
config/routes.rb
config/routes.rb
+5
-0
spec/models/environment_spec.rb
spec/models/environment_spec.rb
+3
-3
No files found.
app/controllers/projects/merge_requests_controller.rb
View file @
88b03bb5
...
...
@@ -404,29 +404,34 @@ class Projects::MergeRequestsController < Projects::ApplicationController
end
def
ci_environments_status
render
json:
@merge_request
.
environments
.
map
do
|
environment
|
next
unless
can?
(
current_user
,
:read_environment
,
environment
)
deployment
=
environment
.
first_deployment_for
(
@merge_request
.
diff_head_commit
)
environments
=
begin
@merge_request
.
environments
.
map
do
|
environment
|
next
unless
can?
(
current_user
,
:read_environment
,
environment
)
deployment
=
environment
.
first_deployment_for
(
@merge_request
.
diff_head_commit
)
environment_data
=
{
name:
environment
.
name
,
id:
environment
.
id
,
url:
namespace_project_environment_path
(
@project
.
namespace
,
@project
,
environment
),
external_url:
environment
.
external_url
,
deployed_at:
deployment
?
deployment
.
created_at
:
nil
}
environment_data
=
{
name:
environment
.
name
,
id:
environment
.
id
,
url:
namespace_project_environment_path
(
@project
.
namespace
,
@project
,
environment
),
external_url:
environment
.
external_url
,
deployed_at:
deployment
?
deployment
.
created_at
:
nil
}
if
environment_data
[
:external_url
]
environment_data
[
:external_url_formatted
]
=
environment_data
[
:external_url
].
gsub
(
/\A.*?:\/\//
,
''
)
end
if
environment_data
[
:external_url
]
environment_data
[
:external_url_formatted
]
=
environment_data
[
:external_url
].
gsub
(
/\A.*?:\/\//
,
''
)
end
if
environment_data
[
:deployed_at
]
environment_data
[
:deployed_at_formatted
]
=
environment_data
[
:deployed_at
].
to_time
.
in_time_zone
.
to_s
(
:medium
)
end
if
environment_data
[
:deployed_at
]
en
vironment_data
[
:deployed_at_formatted
]
=
environment_data
[
:deployed_at
].
to_time
.
in_time_zone
.
to_s
(
:medium
)
environment_data
en
d
.
compact
end
environment_data
end
.
compact
render
json:
environments
end
protected
...
...
config/routes.rb
View file @
88b03bb5
...
...
@@ -83,4 +83,9 @@ Rails.application.routes.draw do
draw
:group
draw
:user
draw
:project
# Get all keys of user
get
':username.keys'
=>
'profiles/keys#get_keys'
,
constraints:
{
username:
/.*/
}
root
to:
"root#index"
end
spec/models/environment_spec.rb
View file @
88b03bb5
...
...
@@ -64,7 +64,7 @@ describe Environment, models: true do
end
end
describe
'#
deployment_id
_for'
do
describe
'#
first_deployment
_for'
do
let
(
:project
)
{
create
(
:project
)
}
let!
(
:environment
)
{
create
(
:environment
,
project:
project
)
}
let!
(
:deployment
)
{
create
(
:deployment
,
environment:
environment
,
ref:
commit
.
parent
.
id
)
}
...
...
@@ -73,11 +73,11 @@ describe Environment, models: true do
let
(
:commit
)
{
project
.
commit
.
parent
}
it
'returns deployment id for the environment'
do
expect
(
environment
.
deployment_id_for
(
commit
)).
to
eq
deployment1
.
id
expect
(
environment
.
first_deployment_for
(
commit
)).
to
eq
deployment1
end
it
'return nil when no deployment is found'
do
expect
(
environment
.
deployment_id
_for
(
head_commit
)).
to
eq
nil
expect
(
environment
.
first_deployment
_for
(
head_commit
)).
to
eq
nil
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