Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGrzegorz Bizon <grzesiek.bizon@gmail.com>2017-05-03 16:42:29 +0300
committerGrzegorz Bizon <grzesiek.bizon@gmail.com>2017-05-03 16:42:29 +0300
commit83154f21542ec04076d20ce9c4a8997d55fc5f43 (patch)
treec5e8f755224401928d1ac55edcc1851ed6211008 /app/policies
parent88ace4a7ad0809d64f688dc1ee6fc8ea6cda9045 (diff)
Improve environment policy class
Diffstat (limited to 'app/policies')
-rw-r--r--app/policies/environment_policy.rb12
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