2018-07-24 06:00:56 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-08-18 13:40:39 -04:00
|
|
|
class DeploymentPolicy < BasePolicy
|
2017-04-06 17:06:42 -04:00
|
|
|
delegate { @subject.project }
|
2018-10-23 06:58:41 -04:00
|
|
|
|
|
|
|
condition(:can_retry_deployable) do
|
|
|
|
can?(:update_build, @subject.deployable)
|
|
|
|
end
|
|
|
|
|
2019-10-16 14:08:01 -04:00
|
|
|
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-10-23 06:58:41 -04:00
|
|
|
prevent :create_deployment
|
|
|
|
prevent :update_deployment
|
|
|
|
end
|
2019-10-16 14:08:01 -04:00
|
|
|
|
|
|
|
rule { ~can_update_deployment }.policy do
|
|
|
|
prevent :update_deployment
|
|
|
|
end
|
2016-08-18 13:40:39 -04:00
|
|
|
end
|
2022-07-26 02:11:51 -04:00
|
|
|
|
|
|
|
DeploymentPolicy.prepend_mod_with('DeploymentPolicy')
|