Skip to content

Commit

Permalink
fix: Sub-actors not appearing for Actor Developer roles
Browse files Browse the repository at this point in the history
  • Loading branch information
mromulus committed Oct 21, 2024
1 parent 99deccc commit b0f6a27
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions app/policies/actor_policy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,17 @@ def destroy?

relation_scope(:vm_dev) do |relation|
next relation if user.super_admin?
actor_dev = Actor.arel_table[:id].eq(RoleBinding.arel_table[:actor_id]).and(
RoleBinding.arel_table[:role].eq(:actor_dev)
)
developer_actors = Actor.where(
id: RoleBinding.for_user(user).where(role: :actor_dev).pluck(:actor_id)
).flat_map(&:subtree_ids)

is_env_role = Actor.arel_table[:exercise_id].eq(RoleBinding.arel_table[:exercise_id])
actor_admin = is_env_role.and(RoleBinding.arel_table[:role].in([:environment_admin]))
relation
.joins(:exercise)
.merge(Exercise.for_user(user))
.where(
actor_dev
Actor.arel_table[:id].in(developer_actors)
.or(actor_admin)
)
end
Expand Down

0 comments on commit b0f6a27

Please sign in to comment.