diff options
author | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2017-05-01 14:38:57 +0300 |
---|---|---|
committer | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2017-05-01 14:38:57 +0300 |
commit | 6baaa8a98e10ff93ba3f481052bb68fdafb6e2c1 (patch) | |
tree | 6b595de63b26a823d63d0d1d5a7089bf68fe9bd7 /app/policies/environment_policy.rb | |
parent | 52bfc0efa95f991f17618aa049f799f4e44e13ac (diff) |
Add new ability check for stopping environment
Diffstat (limited to 'app/policies/environment_policy.rb')
-rw-r--r-- | app/policies/environment_policy.rb | 13 |
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 |