debian-mirror-gitlab/app/policies/deployment_policy.rb

27 lines
573 B
Ruby
Raw Normal View History

2018-11-18 11:00:15 +05:30
# frozen_string_literal: true
2016-09-29 09:46:39 +05:30
class DeploymentPolicy < BasePolicy
2017-09-10 17:25:29 +05:30
delegate { @subject.project }
2018-12-13 13:39:08 +05:30
condition(:can_retry_deployable) do
can?(:update_build, @subject.deployable)
end
2019-12-21 20:55:43 +05:30
condition(:has_deployable) do
@subject.deployable.present?
end
condition(:can_update_deployment) do
can?(:update_deployment, @subject.environment)
end
rule { has_deployable & ~can_retry_deployable }.policy do
2018-12-13 13:39:08 +05:30
prevent :create_deployment
prevent :update_deployment
end
2019-12-21 20:55:43 +05:30
rule { ~can_update_deployment }.policy do
prevent :update_deployment
end
2016-09-29 09:46:39 +05:30
end