2016-08-18 13:40:39 -04:00
|
|
|
class EnvironmentPolicy < BasePolicy
|
2017-05-01 07:38:57 -04:00
|
|
|
alias_method :environment, :subject
|
|
|
|
|
2016-08-18 13:40:39 -04:00
|
|
|
def rules
|
2017-05-01 07:38:57 -04:00
|
|
|
delegate! environment.project
|
|
|
|
|
2017-05-03 09:42:29 -04:00
|
|
|
if can?(:create_deployment) && environment.stop_action?
|
|
|
|
can! :stop_environment if can_play_stop_action?
|
2017-05-01 07:38:57 -04:00
|
|
|
end
|
2017-05-03 09:42:29 -04:00
|
|
|
end
|
2017-05-01 07:38:57 -04:00
|
|
|
|
2017-05-03 09:42:29 -04:00
|
|
|
private
|
|
|
|
|
|
|
|
def can_play_stop_action?
|
2017-05-05 06:25:24 -04:00
|
|
|
Ability.allowed?(user, :update_build, environment.stop_action)
|
2016-08-18 13:40:39 -04:00
|
|
|
end
|
|
|
|
end
|