|
15 | 15 | end |
16 | 16 | end |
17 | 17 |
|
| 18 | + describe 'GET #student' do |
| 19 | + let(:member) { Fabricate(:member) } |
| 20 | + let(:event) { Fabricate(:event) } |
| 21 | + |
| 22 | + before { login(member) } |
| 23 | + |
| 24 | + context 'when the member already has an invitation for the event and role with attending nil' do |
| 25 | + let!(:invitation) do |
| 26 | + Fabricate(:invitation, event: event, member: member, role: 'Student', attending: nil) |
| 27 | + end |
| 28 | + |
| 29 | + it 'redirects to the existing invitation page' do |
| 30 | + get :student, params: { event_id: event.slug } |
| 31 | + |
| 32 | + expect(response).to redirect_to(event_invitation_path(event, invitation)) |
| 33 | + end |
| 34 | + |
| 35 | + it 'does not create a new invitation' do |
| 36 | + expect do |
| 37 | + get :student, params: { event_id: event.slug } |
| 38 | + end.not_to change(Invitation, :count) |
| 39 | + end |
| 40 | + end |
| 41 | + |
| 42 | + context 'when the member does not have an invitation for the event and role' do |
| 43 | + it 'creates a new invitation and redirects' do |
| 44 | + expect do |
| 45 | + get :student, params: { event_id: event.slug } |
| 46 | + end.to change(Invitation, :count).by(1) |
| 47 | + |
| 48 | + invitation = Invitation.last |
| 49 | + expect(response).to redirect_to(event_invitation_path(event, invitation)) |
| 50 | + end |
| 51 | + end |
| 52 | + end |
| 53 | + |
| 54 | + describe 'GET #coach' do |
| 55 | + let(:member) { Fabricate(:member) } |
| 56 | + let(:event) { Fabricate(:event) } |
| 57 | + |
| 58 | + before { login(member) } |
| 59 | + |
| 60 | + context 'when the member already has a coach invitation for the event with attending nil' do |
| 61 | + let!(:invitation) do |
| 62 | + Fabricate(:coach_invitation, event: event, member: member, attending: nil) |
| 63 | + end |
| 64 | + |
| 65 | + it 'redirects to the existing invitation page' do |
| 66 | + get :coach, params: { event_id: event.slug } |
| 67 | + |
| 68 | + expect(response).to redirect_to(event_invitation_path(event, invitation)) |
| 69 | + end |
| 70 | + |
| 71 | + it 'does not create a new invitation' do |
| 72 | + expect do |
| 73 | + get :coach, params: { event_id: event.slug } |
| 74 | + end.not_to change(Invitation, :count) |
| 75 | + end |
| 76 | + end |
| 77 | + |
| 78 | + context 'when the member does not have a coach invitation for the event' do |
| 79 | + it 'creates a new coach invitation and redirects' do |
| 80 | + expect do |
| 81 | + get :coach, params: { event_id: event.slug } |
| 82 | + end.to change(Invitation, :count).by(1) |
| 83 | + |
| 84 | + invitation = Invitation.last |
| 85 | + expect(response).to redirect_to(event_invitation_path(event, invitation)) |
| 86 | + end |
| 87 | + end |
| 88 | + end |
| 89 | + |
18 | 90 | describe '#past' do |
19 | 91 | before { Fabricate(:event, date_and_time: 2.weeks.ago) } |
20 | 92 |
|
|
0 commit comments