Skip to content

Conversation

@mroderick
Copy link
Collaborator

Summary

Adds test coverage for all 11 authorization policy files that were previously untested. Policies control access to admin functions and sensitive data, making this coverage critical for security.

Test Coverage Results

  • 62 new policy tests (all passing)
  • 10 of 11 policies: 100% coverage
  • ApplicationPolicy: 92.59% (base class with helper methods)
  • Overall project coverage: 95.22% (up from 95.08%)

Policies Tested

  • AdminPortalPolicy (2 tests)
  • ApplicationPolicy (6 tests)
  • ChapterPolicy (12 tests)
  • ContactPolicy (2 tests)
  • EventPolicy (4 tests)
  • GroupPolicy (4 tests)
  • MemberNotePolicy (2 tests)
  • OrganiserPolicy (6 tests)
  • SponsorPolicy (10 tests)
  • TestimonialPolicy (2 tests)
  • WorkshopPolicy (12 tests)

Testing Pattern

Each policy test follows a consistent pattern testing authorization boundaries:

  • Happy path: Admin user can perform action
  • Sad path: Regular member without roles is denied

Tests use Fabrication for test data and Rolify for role assignment, matching existing codebase patterns.

Verification

Run policy tests:

bundle exec rspec spec/policies/

Expected: 62 examples, 0 failures

Security Impact

This PR establishes test coverage for security-critical authorization logic. Before this PR, policy bugs could allow unauthorized access to admin functions or sensitive member data without being caught by tests.

Adds test coverage for all 11 authorization policy files that were
previously untested. Policies control access to admin functions and
sensitive data, making this coverage critical for security.

Test Coverage Results:
- 62 new policy tests (all passing)
- 10 of 11 policies: 100% coverage
- ApplicationPolicy: 92.59% (base class)
- Overall project: 95.22% coverage (up from 95.08%)

Policies Tested:
- AdminPortalPolicy (2 tests)
- ApplicationPolicy (6 tests)
- ChapterPolicy (12 tests)
- ContactPolicy (2 tests)
- EventPolicy (4 tests)
- GroupPolicy (4 tests)
- MemberNotePolicy (2 tests)
- OrganiserPolicy (6 tests)
- SponsorPolicy (10 tests)
- TestimonialPolicy (2 tests)
- WorkshopPolicy (12 tests)

Testing Pattern:
Each policy test follows a consistent pattern testing authorization
boundaries with happy path (admin succeeds) and sad path (regular
member denied) scenarios. Tests use Fabrication for test data and
Rolify for role assignment, matching existing codebase patterns.
@mroderick mroderick marked this pull request as ready for review February 1, 2026 17:41
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.

1 participant