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

environment_policy.rb « policies « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: be512dd3b9466c4048d363c7b9ec8e268e9bce4a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# frozen_string_literal: true

class EnvironmentPolicy < BasePolicy
  delegate { @subject.project }

  condition(:stop_with_deployment_allowed) do
    @subject.stop_action_available? &&
      can?(:create_deployment) && can?(:update_build, @subject.stop_action)
  end

  condition(:stop_with_update_allowed) do
    !@subject.stop_action_available? && can?(:update_environment, @subject)
  end

  rule { stop_with_deployment_allowed | stop_with_update_allowed }.enable :stop_environment
end

EnvironmentPolicy.prepend_if_ee('EE::EnvironmentPolicy')