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