summaryrefslogtreecommitdiff
path: root/app/services
diff options
context:
space:
mode:
authorGrzegorz Bizon <grzesiek.bizon@gmail.com>2017-05-01 13:38:57 +0200
committerGrzegorz Bizon <grzesiek.bizon@gmail.com>2017-05-01 13:38:57 +0200
commit6baaa8a98e10ff93ba3f481052bb68fdafb6e2c1 (patch)
tree6b595de63b26a823d63d0d1d5a7089bf68fe9bd7 /app/services
parent52bfc0efa95f991f17618aa049f799f4e44e13ac (diff)
downloadgitlab-ce-6baaa8a98e10ff93ba3f481052bb68fdafb6e2c1.tar.gz
Add new ability check for stopping environment
Diffstat (limited to 'app/services')
-rw-r--r--app/services/ci/stop_environments_service.rb9
1 files changed, 2 insertions, 7 deletions
diff --git a/app/services/ci/stop_environments_service.rb b/app/services/ci/stop_environments_service.rb
index bd9735fc0ac..43c9a065fcf 100644
--- a/app/services/ci/stop_environments_service.rb
+++ b/app/services/ci/stop_environments_service.rb
@@ -5,12 +5,11 @@ module Ci
def execute(branch_name)
@ref = branch_name
- return unless has_ref?
- return unless can?(current_user, :create_deployment, project)
+ return unless @ref.present?
environments.each do |environment|
next unless environment.stop_action?
- next unless can?(current_user, :play_build, environment.stop_action)
+ next unless can?(current_user, :stop_environment, environment)
environment.stop_with_action!(current_user)
end
@@ -18,10 +17,6 @@ module Ci
private
- def has_ref?
- @ref.present?
- end
-
def environments
@environments ||= EnvironmentsFinder
.new(project, current_user, ref: @ref, recently_updated: true)