diff options
Diffstat (limited to 'app/policies')
-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 |