summaryrefslogtreecommitdiff
path: root/app/policies
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/policies
parent52bfc0efa95f991f17618aa049f799f4e44e13ac (diff)
downloadgitlab-ce-6baaa8a98e10ff93ba3f481052bb68fdafb6e2c1.tar.gz
Add new ability check for stopping environment
Diffstat (limited to 'app/policies')
-rw-r--r--app/policies/environment_policy.rb13
1 files changed, 12 insertions, 1 deletions
diff --git a/app/policies/environment_policy.rb b/app/policies/environment_policy.rb
index f4219569161..0b976e5664d 100644
--- a/app/policies/environment_policy.rb
+++ b/app/policies/environment_policy.rb
@@ -1,5 +1,16 @@
class EnvironmentPolicy < BasePolicy
+
+ alias_method :environment, :subject
+
def rules
- delegate! @subject.project
+ delegate! environment.project
+
+ if environment.stop_action?
+ delegate! environment.stop_action
+ end
+
+ if can?(:create_deployment) && can?(:play_build)
+ can! :stop_environment
+ end
end
end