Fix: Workshop capacity checks now properly compare attending count with available spaces#2609
Merged
mroderick merged 1 commit intocodebar:masterfrom May 6, 2026
Conversation
…th available spaces PR codebar#2605 changed the capacity check methods from student_spaces?/ coach_spaces? to event_student_spaces?/event_coach_spaces?, but the new methods in EventPresenter called model.student_spaces? which just checks if the attribute is present (truthy), not if spaces are actually available. This fix adds proper event_student_spaces? and event_coach_spaces? methods to WorkshopPresenter that correctly compare the number of attending students/coaches with the available spaces from the workshop model (using model.student_spaces and model.coach_spaces). This ensures that: - When 2 students attend a workshop with 2 spaces, event_student_spaces? returns false (correctly indicating the workshop is full) - When 1 student attends a workshop with 2 spaces, event_student_spaces? returns true (correctly indicating space is available) Fixes the bug where workshops showed as full even when spaces were available, and vice versa.
KimberleyCook
approved these changes
May 6, 2026
Contributor
KimberleyCook
left a comment
There was a problem hiding this comment.
Wow!! That was quick 🚀
mroderick
added a commit
that referenced
this pull request
May 6, 2026
PR #2609 changed WorkshopPresenter to use model.student_spaces and model.coach_spaces for capacity checks, but this broke in-person workshops that rely on sponsor capacity. Most in-person workshops have student_spaces=0 and coach_spaces=0 in the database, with actual capacity coming from the sponsor/venue. This fix changes event_student_spaces? and event_coach_spaces? to use the presenter methods student_spaces and coach_spaces, which delegate to the sponsor for in-person workshops. - In-person workshops: use venue.seats and venue.coach_spots - Virtual workshops: use model.student_spaces and model.coach_spaces Fixes: Workshops incorrectly showing as full when sponsor has capacity
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.
This PR fixes a bug introduced in #2605 where workshop capacity checks were not working correctly.
Problem
PR #2605 changed the capacity check methods from
student_spaces?/coach_spaces?toevent_student_spaces?/event_coach_spaces?, but the new methods inherited fromEventPresentercalledmodel.student_spaces?which just checks if the attribute is present (truthy), not if spaces are actually available.This caused workshops to incorrectly show as full when spaces were available, and vice versa.
Solution
Added proper
event_student_spaces?andevent_coach_spaces?methods toWorkshopPresenterthat correctly compare the number of attending students/coaches with the available spaces:Key Fix
Uses
model.student_spaces(the database column) instead ofstudent_spaces(the presenter method that delegates tovenue.seats). This ensures that when tests or admins setworkshop.student_spaces = 0, the capacity check respects that value rather than reading from the venue.Testing
spec/presenters/workshop_presenter_capacity_spec.rbwith 4 test casesBug Report Context
From Slack: