Skip to content

Commit c461e8c

Browse files
committed
Fix workshop capacity checks
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.
1 parent a3dcfcc commit c461e8c

5 files changed

Lines changed: 9 additions & 7 deletions

File tree

β€Žapp/controllers/workshop_invitation_controller.rbβ€Ž

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,8 @@ def invitation_params
9191
end
9292

9393
def available_spaces?(workshop, invitation)
94-
(invitation.role.eql?('Student') && workshop.student_spaces?) ||
95-
(invitation.role.eql?('Coach') && workshop.coach_spaces?)
94+
(invitation.role.eql?('Student') && workshop.event_student_spaces?) ||
95+
(invitation.role.eql?('Coach') && workshop.event_coach_spaces?)
9696
end
9797

9898
# Inline from InvitationControllerConcerns

β€Žapp/views/workshop_invitation/show.html.hamlβ€Ž

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@
8080
= @invitation.member.bans.active.first.reason
8181
- else
8282
- if @invitation.for_coach?
83-
- if @workshop.coach_spaces?
83+
- if @workshop.event_coach_spaces?
8484
= link_to 'Keep your skills up-to-date!', edit_member_path
8585
%span.d-block
8686
%small= I18n.t('workshop_invitation.coach_skills_tooltip')
@@ -91,7 +91,7 @@
9191
- else
9292
= render partial: 'workshop_invitation/waiting_list', locals: { invitation: @invitation }
9393
- else
94-
- if @workshop.student_spaces?
94+
- if @workshop.event_student_spaces?
9595
= simple_form_for @invitation, url: :accept_invitation, method: :post do |f|
9696
= f.input :tutorial, collection: @tutorial_titles, include_blank: true
9797
= f.input :note, required: false, input_html: { rows: 3, maxlength: 100 }, hint: 'Anything else we should know?', placeholder: 'e.g. I need help understanding selectors'

β€Žspec/fabricators/workshop_fabricator.rbβ€Ž

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,14 @@
22
date_and_time Time.zone.now + 2.days
33
ends_at { |attrs| attrs[:date_and_time] + 2.hours }
44
chapter
5+
student_spaces { |transients| transients[:student_count] || 10 }
6+
coach_spaces { |transients| transients[:coach_count] || 10 }
57
after_build do |workshop, transients|
68
Fabricate(:workshop_sponsor,
79
workshop: workshop,
810
sponsor: Fabricate(:sponsor,
911
seats: transients[:student_count] || 10,
10-
number_of_coaches: transients[:coach_count || 10]),
12+
number_of_coaches: transients[:coach_count] || 10),
1113
host: true)
1214
end
1315

β€Žspec/features/accepting_invitation_spec.rbβ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
let(:invitation_route) { invitation_path(invitation) }
66
let(:accept_invitation_route) { accept_invitation_path(invitation) }
77
let(:reject_invitation_route) { reject_invitation_path(invitation) }
8-
let(:set_no_available_slots) { invitation.workshop.host.update_attribute(:seats, 0) }
8+
let(:set_no_available_slots) { invitation.workshop.update_attribute(:student_spaces, 0) }
99
let!(:tutorial) { Fabricate(:tutorial) }
1010

1111
it_behaves_like 'invitation route'

β€Žspec/features/coach_accepting_invitation_spec.rbβ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
let(:reject_invitation_route) { reject_invitation_path(invitation) }
77
let(:accept_invitation_route) { accept_invitation_path(invitation) }
88

9-
let(:set_no_available_slots) { invitation.workshop.host.update_attribute(:seats, 0) }
9+
let(:set_no_available_slots) { invitation.workshop.update_attribute(:coach_spaces, 0) }
1010

1111
before(:each) do
1212
login(member)

0 commit comments

Comments
Β (0)