summaryrefslogtreecommitdiff
path: root/app/policies
diff options
context:
space:
mode:
authorWinnie Hellmann <winnie@gitlab.com>2018-07-10 08:11:04 +0000
committerPhil Hughes <me@iamphill.com>2018-07-10 08:11:04 +0000
commitd79cef3a9a5577765d975326fbf4bc1b8c5634de (patch)
treefad8dce6f89102fda75f511dee80b7fae7675994 /app/policies
parentca1deb9e5ec1429a65d73b3352d1207301f9fc6f (diff)
downloadgitlab-ce-d79cef3a9a5577765d975326fbf4bc1b8c5634de.tar.gz
Support manually stopping any environment from the UI
Diffstat (limited to 'app/policies')
-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