summaryrefslogtreecommitdiff
path: root/app/policies/environment_policy.rb
blob: cc94d4a7e058e574a8b4e29d2fd3b140471df667 (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, :play_build, environment.stop_action)
  end
end