summaryrefslogtreecommitdiff
path: root/app/policies/environment_policy.rb
blob: 2fa15e645629ba69cf14112a380e64f3631ff771 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
class EnvironmentPolicy < BasePolicy
  alias_method :environment, :subject

  def rules
    delegate! environment.project

    if can?(:create_deployment) && environment.stop_action?
      can! :stop_environment if can_play_stop_action?
    end
  end

  private

  def can_play_stop_action?
    Ability.allowed?(user, :update_build, environment.stop_action)
  end
end