Skip to content

Add ApplicationPolicy default permission and scope regression specs - #287

Merged
rsmoke merged 2 commits into
stagingfrom
cursor/application-policy-coverage-e7b2
Oct 14, 2026
Merged

rsmoke merged 2 commits into
stagingfrom
cursor/application-policy-coverage-e7b2

Conversation

@cursor

@cursor cursor Bot commented Oct 3, 2026 •

Copy link
Copy Markdown

Risky behavior now covered

  • Default CRUD actions (index/show/create/new/update/edit/destroy) grant only Axis Mundi users
  • Regular and nil users are denied those defaults
  • ApplicationPolicy::Scope#resolve returns all records for Axis Mundi and none for regular/nil users

Test 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.
Open in Web View Automation 

Note

Low Risk
Test-only change with no production or authorization logic modifications.

Overview
Adds regression specs for ApplicationPolicy so inherited default authorization behavior stays locked in.

The new spec/policies/application_policy_spec.rb asserts 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 covers ApplicationPolicy::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.

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>
@rsmoke
rsmoke marked this pull request as ready for review October 14, 2026 13:23
@rsmoke
rsmoke self-requested a review as a code owner October 14, 2026 13:23
Copilot AI balanced review requested due to automatic review settings October 14, 2026 13:23

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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) }

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>
@rsmoke
rsmoke merged commit f2b5ac2 into staging Oct 14, 2026
6 checks passed
@rsmoke
rsmoke deleted the cursor/application-policy-coverage-e7b2 branch October 14, 2026 13:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants