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