Skip to content

Commit

Permalink
Add missing policy association
Browse files Browse the repository at this point in the history
  • Loading branch information
segiddins committed Aug 19, 2023
1 parent 488c7c2 commit bed1866
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
1 change: 1 addition & 0 deletions app/policies/user_policy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,5 @@ def act_on?
has_association :ownership_requests
has_association :pushed_versions
has_association :audits
has_association :oidc_api_key_roles
end
22 changes: 14 additions & 8 deletions test/policies/avo_policies_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,23 @@ def test_association_methods_defined
resources = Avo::App.init_resources
association_actions = %w[create attach detach destroy edit show view]

resources.each do |resource|
policy = Pundit.policy(nil, resource)
aggregate_assertions do
resources.each do |resource|
policy = Pundit.policy(nil, resource)

refute_nil policy
refute_nil policy

resource.fields.each do |field|
case field
when Avo::Fields::HasBaseField
aggregate_assertions policy.class.name do
resource.fields.each do |field|
aggregate_assertions field.id do
case field
when Avo::Fields::HasBaseField

association_actions.each do |action|
assert_respond_to policy, :"#{action}_#{field.id}?"
association_actions.each do |action|
assert_respond_to policy, :"#{action}_#{field.id}?"
end
end
end
end
end
end
Expand Down

0 comments on commit bed1866

Please sign in to comment.