Improve environment policy class
This commit is contained in:
parent
88ace4a7ad
commit
83154f2154
|
@ -4,12 +4,14 @@ class EnvironmentPolicy < BasePolicy
|
||||||
def rules
|
def rules
|
||||||
delegate! environment.project
|
delegate! environment.project
|
||||||
|
|
||||||
if environment.stop_action?
|
if can?(:create_deployment) && environment.stop_action?
|
||||||
delegate! environment.stop_action
|
can! :stop_environment if can_play_stop_action?
|
||||||
end
|
|
||||||
|
|
||||||
if can?(:create_deployment) && can?(:play_build)
|
|
||||||
can! :stop_environment
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def can_play_stop_action?
|
||||||
|
Ability.allowed?(user, :play_build, environment.stop_action)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue