summaryrefslogtreecommitdiff
path: root/app/policies/deployment_policy.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/policies/deployment_policy.rb')
-rw-r--r--app/policies/deployment_policy.rb14
1 files changed, 13 insertions, 1 deletions
diff --git a/app/policies/deployment_policy.rb b/app/policies/deployment_policy.rb
index d4f2f3c52b1..1a92b735e36 100644
--- a/app/policies/deployment_policy.rb
+++ b/app/policies/deployment_policy.rb
@@ -7,8 +7,20 @@ class DeploymentPolicy < BasePolicy
can?(:update_build, @subject.deployable)
end
- rule { ~can_retry_deployable }.policy do
+ 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
prevent :create_deployment
prevent :update_deployment
end
+
+ rule { ~can_update_deployment }.policy do
+ prevent :update_deployment
+ end
end