summaryrefslogtreecommitdiff
path: root/app/controllers/projects
diff options
context:
space:
mode:
authorZ.J. van de Weg <zegerjan@gitlab.com>2016-10-10 20:38:48 +0200
committerZ.J. van de Weg <zegerjan@gitlab.com>2016-10-14 11:07:01 +0200
commit88b03bb542a8480d61c260a9dc3769ab791995e5 (patch)
tree69017bb97fc5dd84e52a71ca526c9b59d0441956 /app/controllers/projects
parent58368fbc53bfe7c2a9b425626819eae576afff09 (diff)
downloadgitlab-ce-88b03bb542a8480d61c260a9dc3769ab791995e5.tar.gz
Rename method in test
Diffstat (limited to 'app/controllers/projects')
-rw-r--r--app/controllers/projects/merge_requests_controller.rb41
1 files changed, 23 insertions, 18 deletions
diff --git a/app/controllers/projects/merge_requests_controller.rb b/app/controllers/projects/merge_requests_controller.rb
index e17d560138f..5f7f46cf566 100644
--- a/app/controllers/projects/merge_requests_controller.rb
+++ b/app/controllers/projects/merge_requests_controller.rb
@@ -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]
- environment_data[:deployed_at_formatted] = environment_data[:deployed_at].to_time.in_time_zone.to_s(:medium)
+ environment_data
+ end.compact
end
- environment_data
- end.compact
+ render json: environments
end
protected