diff options
author | Kamil Trzcinski <ayufan@ayufan.eu> | 2016-11-10 13:59:26 +0100 |
---|---|---|
committer | Kamil Trzcinski <ayufan@ayufan.eu> | 2016-11-10 13:59:26 +0100 |
commit | 1494abe982583c564969baaba7daa251ef333156 (patch) | |
tree | 681b777b50e645e6af0496bc808a2c071a4250ee /app/controllers | |
parent | 13a680e343bdcd905c9134c57202fdec7d436d96 (diff) | |
download | gitlab-ce-1494abe982583c564969baaba7daa251ef333156.tar.gz |
Allow to stop any environment
Diffstat (limited to 'app/controllers')
-rw-r--r-- | app/controllers/projects/environments_controller.rb | 10 | ||||
-rw-r--r-- | app/controllers/projects/merge_requests_controller.rb | 2 |
2 files changed, 8 insertions, 4 deletions
diff --git a/app/controllers/projects/environments_controller.rb b/app/controllers/projects/environments_controller.rb index ea22b2dcc15..bc66823dfc4 100644 --- a/app/controllers/projects/environments_controller.rb +++ b/app/controllers/projects/environments_controller.rb @@ -47,10 +47,14 @@ class Projects::EnvironmentsController < Projects::ApplicationController end def stop - return render_404 unless @environment.stoppable? + return render_404 unless @environment.available? - new_action = @environment.stop!(current_user) - redirect_to polymorphic_path([project.namespace.becomes(Namespace), project, new_action]) + stop_action = @environment.run_stop!(current_user) + if stop_action + redirect_to polymorphic_path([project.namespace.becomes(Namespace), project, stop_action]) + else + redirect_to namespace_project_environment_path(project.namespace, project, @environment) + end end private diff --git a/app/controllers/projects/merge_requests_controller.rb b/app/controllers/projects/merge_requests_controller.rb index 9f104d903cc..ccba37c9c5c 100644 --- a/app/controllers/projects/merge_requests_controller.rb +++ b/app/controllers/projects/merge_requests_controller.rb @@ -436,7 +436,7 @@ class Projects::MergeRequestsController < Projects::ApplicationController deployment = environment.first_deployment_for(@merge_request.diff_head_commit) stop_url = - if environment.stoppable? && can?(current_user, :create_deployment, environment) + if environment.can_run_stop_action? && can?(current_user, :create_deployment, environment) stop_namespace_project_environment_path(project.namespace, project, environment) end |