diff options
author | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2017-05-03 15:42:29 +0200 |
---|---|---|
committer | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2017-05-03 15:42:29 +0200 |
commit | 83154f21542ec04076d20ce9c4a8997d55fc5f43 (patch) | |
tree | c5e8f755224401928d1ac55edcc1851ed6211008 | |
parent | 88ace4a7ad0809d64f688dc1ee6fc8ea6cda9045 (diff) | |
download | gitlab-ce-83154f21542ec04076d20ce9c4a8997d55fc5f43.tar.gz |
Improve environment policy class
-rw-r--r-- | app/policies/environment_policy.rb | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/app/policies/environment_policy.rb b/app/policies/environment_policy.rb index c0c9bbf2d9e..cc94d4a7e05 100644 --- a/app/policies/environment_policy.rb +++ b/app/policies/environment_policy.rb @@ -4,12 +4,14 @@ class EnvironmentPolicy < BasePolicy def rules delegate! environment.project - if environment.stop_action? - delegate! environment.stop_action + if can?(:create_deployment) && environment.stop_action? + can! :stop_environment if can_play_stop_action? end + end - if can?(:create_deployment) && can?(:play_build) - can! :stop_environment - end + private + + def can_play_stop_action? + Ability.allowed?(user, :play_build, environment.stop_action) end end |