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

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

25 lines
660 B
Ruby
Raw Normal View History

# frozen_string_literal: true
class EnvironmentPolicy < BasePolicy
delegate { @subject.project }
condition(:stop_with_deployment_allowed) do
@subject.stop_actions_available? &&
can?(:create_deployment) && can?(:update_build, @subject.stop_actions.last)
2017-05-03 09:42:29 -04:00
end
condition(:stop_with_update_allowed) do
!@subject.stop_actions_available? && can?(:update_environment, @subject)
end
condition(:stopped) do
@subject.stopped?
end
rule { stop_with_deployment_allowed | stop_with_update_allowed }.enable :stop_environment
rule { ~stopped }.prevent(:destroy_environment)
end
EnvironmentPolicy.prepend_mod_with('EnvironmentPolicy')