2018-07-24 10:00:56 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-08-18 17:40:39 +00:00
|
|
|
class EnvironmentPolicy < BasePolicy
|
2017-04-06 21:06:42 +00:00
|
|
|
delegate { @subject.project }
|
2017-05-01 11:38:57 +00:00
|
|
|
|
2018-07-10 08:11:04 +00:00
|
|
|
condition(:stop_with_deployment_allowed) do
|
2018-07-12 10:22:11 +00:00
|
|
|
@subject.stop_action_available? &&
|
|
|
|
can?(:create_deployment) && can?(:update_build, @subject.stop_action)
|
2017-05-03 13:42:29 +00:00
|
|
|
end
|
2017-05-01 11:38:57 +00:00
|
|
|
|
2018-07-10 08:11:04 +00:00
|
|
|
condition(:stop_with_update_allowed) do
|
2018-07-12 10:22:11 +00:00
|
|
|
!@subject.stop_action_available? && can?(:update_environment, @subject)
|
2018-07-10 08:11:04 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
rule { stop_with_deployment_allowed | stop_with_update_allowed }.enable :stop_environment
|
2016-08-18 17:40:39 +00:00
|
|
|
end
|