2016-09-29 09:46:39 +05:30
|
|
|
class EnvironmentPolicy < BasePolicy
|
2017-08-17 22:00:37 +05:30
|
|
|
alias_method :environment, :subject
|
|
|
|
|
2016-09-29 09:46:39 +05:30
|
|
|
def rules
|
2017-08-17 22:00:37 +05:30
|
|
|
delegate! environment.project
|
|
|
|
|
|
|
|
if can?(:create_deployment) && environment.stop_action?
|
|
|
|
can! :stop_environment if can_play_stop_action?
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def can_play_stop_action?
|
|
|
|
Ability.allowed?(user, :update_build, environment.stop_action)
|
2016-09-29 09:46:39 +05:30
|
|
|
end
|
|
|
|
end
|