Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWinnie Hellmann <winnie@gitlab.com>2018-07-10 11:11:04 +0300
committerPhil Hughes <me@iamphill.com>2018-07-10 11:11:04 +0300
commitd79cef3a9a5577765d975326fbf4bc1b8c5634de (patch)
treefad8dce6f89102fda75f511dee80b7fae7675994 /app/policies/environment_policy.rb
parentca1deb9e5ec1429a65d73b3352d1207301f9fc6f (diff)
Support manually stopping any environment from the UI
Diffstat (limited to 'app/policies/environment_policy.rb')
-rw-r--r--app/policies/environment_policy.rb10
1 files changed, 7 insertions, 3 deletions
diff --git a/app/policies/environment_policy.rb b/app/policies/environment_policy.rb
index 375a5535359..978dc3a7c81 100644
--- a/app/policies/environment_policy.rb
+++ b/app/policies/environment_policy.rb
@@ -1,9 +1,13 @@
class EnvironmentPolicy < BasePolicy
delegate { @subject.project }
- condition(:stop_action_allowed) do
- @subject.stop_action? && can?(:update_build, @subject.stop_action)
+ condition(:stop_with_deployment_allowed) do
+ @subject.stop_action? && can?(:create_deployment) && can?(:update_build, @subject.stop_action)
end
- rule { can?(:create_deployment) & stop_action_allowed }.enable :stop_environment
+ condition(:stop_with_update_allowed) do
+ !@subject.stop_action? && can?(:update_environment, @subject)
+ end
+
+ rule { stop_with_deployment_allowed | stop_with_update_allowed }.enable :stop_environment
end