Skip to content

Commit 3da4af9

Browse files
authored
Merge pull request #2456 from mroderick/issue-2367-workshop-feedback
Fix empty coaches list in workshop feedback + parallel test improvements
2 parents b2e3164 + 544c848 commit 3da4af9

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)