Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions spec/controllers/workshop_invitation_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,27 @@
expect(waitlisted_invitation.reload.attending).to be true
end
end

context 'when a coach is waitlisted and a student seat frees up' do
let(:coach) { Fabricate(:coach) }
let(:coach_invitation) { Fabricate(:coach_workshop_invitation, workshop:, member: coach) }

before do
invitation.update!(attending: true)
WaitingList.add(coach_invitation, auto_rsvp: true)
end

it 'does not promote the coach invitation' do
post :reject, params: { id: invitation.token }

expect(coach_invitation.reload.attending).to be_nil
end

it 'leaves the waiting list unchanged' do
expect { post :reject, params: { id: invitation.token } }
.not_to change(WaitingList, :count)
end
end
end

describe 'PATCH #update' do
Expand Down
9 changes: 9 additions & 0 deletions spec/models/waiting_list_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,15 @@

expect(described_class.next_spot(workshop, 'Student').invitation).to eq(invitation)
end

it 'ignores an older entry for another role' do
coach_invitation = Fabricate(:coach_workshop_invitation, workshop:, member: Fabricate(:coach))
described_class.add(coach_invitation)

expect(described_class.next_spot(workshop, 'Student')).to be_nil
expect(coach_invitation.reload.attending).to be_nil
expect(described_class.by_workshop(workshop).count).to eq(1)
end
end
end

Expand Down
Loading