Repository navigation
Add ApplicationPolicy default permission and scope regression specs - #287
Merged
Merged
Conversation
Lock down Axis Mundi-only CRUD defaults and Scope#resolve deny-by-default behavior used by campuses, schools, departments, and other catalog resources. Co-authored-by: rsmoke <rsmoke@umich.edu>
There was a problem hiding this comment.
🟡 Changes recommended
Nil-user actions and complete privileged scope results are not fully asserted.
2 open findings
What changed in this PR
Adds regression coverage for inherited ApplicationPolicy authorization defaults and scope behavior.
Changes:
- Tests CRUD permissions for privileged and unprivileged users.
- Tests scope resolution for privileged, regular, and nil users.
| File | Description |
|---|---|
spec/policies/application_policy_spec.rb |
Adds default permission and scope regression specs. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+28
to
+29
| it { is_expected.not_to permit_action(:index) } | ||
| it { is_expected.not_to permit_action(:destroy) } |
Contributor
There was a problem hiding this comment.
Updated the nil-user specs to cover all seven default CRUD actions. Commit: 0af5803.
| user = create(:user, :with_axis_mundi_role) | ||
| scope = described_class::Scope.new(user, Role.all).resolve | ||
|
|
||
| expect(scope).to include(visible_role, hidden_role) |
Contributor
There was a problem hiding this comment.
Updated the scope spec to compare against the complete Role set, including factory-created roles. Commit: 0af5803.
Co-authored-by: rsmoke <5861173+rsmoke@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Risky behavior now covered
index/show/create/new/update/edit/destroy) grant only Axis Mundi usersApplicationPolicy::Scope#resolvereturns all records for Axis Mundi and none for regular/nil usersTest files added/updated
spec/policies/application_policy_spec.rb(new)Why these tests materially reduce regression risk
Empty catalog policies (
Campus,School,Department,EditableContent,Visibility, etc.) inherit these defaults. A change to Axis Mundi gating or Scope deny-by-default would widen or lock down admin CRUD across many resources with no dedicated policy specs today.Validation
bundle exec rspec spec/policies/application_policy_spec.rb— 19 examples, 0 failures.Note
Low Risk
Test-only change with no production or authorization logic modifications.
Overview
Adds regression specs for
ApplicationPolicyso inherited default authorization behavior stays locked in.The new
spec/policies/application_policy_spec.rbasserts that standard CRUD actions (index,show,create,new,update,edit,destroy) are permitted only for Axis Mundi users and denied for regular and nil users. It also coversApplicationPolicy::Scope#resolve, expecting all records for Axis Mundi and an empty scope for everyone else.This is test-only coverage for policies that rely on these defaults without their own specs.
Reviewed by Cursor Bugbot for commit 56175a4. Bugbot is set up for automated code reviews on this repo. Configure here.