gitlab-org--gitlab-foss/app/policies/environment_policy.rb

18 lines
368 B
Ruby
Raw Normal View History

class EnvironmentPolicy < BasePolicy
alias_method :environment, :subject
def rules
delegate! environment.project
2017-05-03 09:42:29 -04:00
if can?(:create_deployment) && environment.stop_action?
can! :stop_environment if can_play_stop_action?
end
2017-05-03 09:42:29 -04:00
end
2017-05-03 09:42:29 -04:00
private
def can_play_stop_action?
Ability.allowed?(user, :update_build, environment.stop_action)
end
end