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