Skip to content

Fix workshop capacity checks#2605

Merged
mroderick merged 1 commit intocodebar:masterfrom
mroderick:fix-workshop-capacity-checks
May 5, 2026
Merged

Fix workshop capacity checks#2605
mroderick merged 1 commit intocodebar:masterfrom
mroderick:fix-workshop-capacity-checks

Conversation

@mroderick
Copy link
Copy Markdown
Collaborator

Summary

This PR fixes a bug in workshop capacity checks where the workshop fabricator had incorrect transient variable syntax, and the controller/view were using venue attributes instead of workshop attributes for capacity checks.

Changes

1. Fix workshop fabricator bug

  • Fixed transients[:coach_count || 10]transients[:coach_count] || 10
  • The bug was causing the coach_count transient to always be nil (truthy || 10 returns 10)
  • Added explicit student_spaces and coach_spaces attributes to workshop fabricator

2. Fix controller capacity checks

  • Updated available_spaces? to use event_student_spaces? and event_coach_spaces?
  • These methods check workshop attributes directly instead of delegating to venue

3. Fix view capacity checks

  • Updated workshop invitation view to use event_coach_spaces? and event_student_spaces?
  • Ensures consistent capacity checking between controller and view

4. Update test files

  • Updated accepting_invitation_spec.rb and coach_accepting_invitation_spec.rb
  • Tests now set workshop.student_spaces and workshop.coach_spaces directly
  • This matches how the controller now checks capacity

Why this fix is needed

The previous implementation checked capacity via the venue (sponsor) attributes:

workshop.host.seats  # venue attribute
workshop.host.number_of_coaches  # venue attribute

But the controller should check workshop attributes directly:

workshop.student_spaces  # workshop attribute
workshop.coach_spaces  # workshop attribute

This ensures that capacity limits are controlled per-workshop, not per-venue.

Testing

All 995 tests pass with this fix.

Fixed bug in workshop fabricator: transients[:coach_count || 10] →
transients[:coach_count] || 10. This was causing incorrect coach
spaces to be set.

Added student_spaces and coach_spaces attributes to workshop fabricator
to ensure capacity checks work correctly.

Updated controller and view to use event_student_spaces? and
event_coach_spaces? methods instead of delegating to venue. This
ensures capacity checks use workshop attributes directly.

Updated test files to set workshop.student_spaces and
workshop.coach_spaces directly for capacity-related tests.
@mroderick
Copy link
Copy Markdown
Collaborator Author

Note on the nature of this bug:

This is a pre-existing bug that we discovered during test optimization work. The capacity checks were inadvertently using venue (sponsor) attributes instead of workshop attributes:

Before (buggy):

  • → checked (sponsor attribute)
  • → checked (sponsor attribute)

After (fixed):

  • → checks directly
  • → checks directly

The tests were passing before because the fabricator was setting up the host with matching attributes, and tests were updating to simulate capacity limits. We discovered the bug when trying to simplify tests to use workshop attributes directly.

@mroderick mroderick marked this pull request as ready for review May 4, 2026 18:43
Copy link
Copy Markdown
Contributor

@KimberleyCook KimberleyCook left a comment

Choose a reason for hiding this comment

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

🎉

@mroderick mroderick merged commit 3fd8bd6 into codebar:master May 5, 2026
8 checks passed
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.

2 participants