Skip to content

Commit 544c848

Browse files
committed
Fix empty coaches list in workshop feedback form (Issue #2367)
Resolves issue where no coaches appeared in the feedback dropdown when students tried to submit workshop feedback. Root cause: The feedback controller was filtering for coaches where attended=true, but attendance is only marked after organizers manually verify it. When feedback emails are sent (the day after workshop), coaches have attending=true but attended=nil. Changes: - Updated set_coaches to use accepted_or_attended scope instead of attended - Added ORDER BY with NULLS LAST to prioritize verified coaches first - Added test for coaches who RSVPd but haven't been verified yet - Added test for verified coaches appearing before unverified coaches This allows students to submit feedback immediately after workshops, even before organizers verify attendance, while still prioritizing verified coaches when that data is available. Fixes #2367
1 parent 095a149 commit 544c848

2 files changed

Lines changed: 48 additions & 1 deletion

File tree

app/controllers/feedback_controller.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ def feedback_params
3838
end
3939

4040
def set_coaches(workshop)
41-
@coaches = workshop.invitations.to_coaches.attended.map(&:member)
41+
@coaches = workshop.invitations.to_coaches.accepted_or_attended
42+
.order(Arel.sql('attended DESC NULLS LAST'))
43+
.map(&:member)
4244
end
4345
end

spec/features/member_feedback_spec.rb

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,51 @@
3838

3939
expect(page).to have_select('feedback_tutorial_id', with_options: [@tutorial.title])
4040
end
41+
42+
scenario 'I can see coaches who RSVPd but have not yet been marked as attended (Issue #2367)' do
43+
# This reproduces the real-world scenario where:
44+
# 1. Coach RSVPs to workshop (attending = true)
45+
# 2. Feedback is sent the next day
46+
# 3. Organizer hasn't yet marked attendance (attended = nil)
47+
coach_not_yet_verified = Fabricate(:coach)
48+
Fabricate(:attending_workshop_invitation,
49+
workshop: feedback_request.workshop,
50+
member: coach_not_yet_verified,
51+
role: 'Coach',
52+
attended: nil)
53+
54+
visit feedback_path(valid_token)
55+
56+
# Coach should appear in the list even though attended is nil
57+
expect(page).to have_select('feedback_coach_id', with_options: [coach_not_yet_verified.full_name])
58+
end
59+
60+
scenario 'verified coaches appear before unverified coaches in the list' do
61+
# Create two coaches: one verified (attended=true), one not yet (attended=nil)
62+
verified_coach = Fabricate(:coach, name: 'Alice', surname: 'Verified')
63+
unverified_coach = Fabricate(:coach, name: 'Bob', surname: 'Unverified')
64+
65+
Fabricate(:attended_workshop_invitation,
66+
workshop: feedback_request.workshop,
67+
member: verified_coach,
68+
role: 'Coach')
69+
70+
Fabricate(:attending_workshop_invitation,
71+
workshop: feedback_request.workshop,
72+
member: unverified_coach,
73+
role: 'Coach',
74+
attended: nil)
75+
76+
visit feedback_path(valid_token)
77+
78+
# Get all coach options in order
79+
select_options = page.find('#feedback_coach_id').all('option').map(&:text).reject(&:blank?)
80+
verified_index = select_options.index(verified_coach.full_name)
81+
unverified_index = select_options.index(unverified_coach.full_name)
82+
83+
# Verified coach should appear before unverified coach
84+
expect(verified_index).to be < unverified_index
85+
end
4186
end
4287

4388
context 'I get redirected to the main page' do

0 commit comments

Comments
 (0)