|
466 | 466 | let!(:vaccinated_patient) do
|
467 | 467 | create(:patient, :vaccinated, session:, programme:)
|
468 | 468 | end
|
469 |
| - let!(:unvaccinated_patient) { create(:patient, session:, programme:) } |
470 | 469 |
|
471 |
| - it "adds the unvaccinated patients to the generic clinic session" do |
472 |
| - location = create(:location, :generic_clinic, organisation:) |
473 |
| - generic_clinic_session = |
474 |
| - create(:session, location:, organisation:, programme:) |
| 470 | + let(:generic_clinic) { create(:location, :generic_clinic, organisation:) } |
| 471 | + let(:generic_clinic_session) do |
| 472 | + create(:session, location: generic_clinic, organisation:, programme:) |
| 473 | + end |
475 | 474 |
|
476 |
| - expect(generic_clinic_session.patients).to be_empty |
| 475 | + context "with an unvaccinated patient" do |
| 476 | + let!(:unvaccinated_patient) { create(:patient, session:, programme:) } |
477 | 477 |
|
478 |
| - close! |
| 478 | + it "adds the unvaccinated patient to the generic clinic session" do |
| 479 | + expect(generic_clinic_session.patients).to be_empty |
479 | 480 |
|
480 |
| - expect(generic_clinic_session.patients).to include(unvaccinated_patient) |
481 |
| - expect(generic_clinic_session.patients).not_to include( |
482 |
| - vaccinated_patient |
483 |
| - ) |
| 481 | + close! |
| 482 | + |
| 483 | + expect(generic_clinic_session.patients).to include( |
| 484 | + unvaccinated_patient |
| 485 | + ) |
| 486 | + expect(generic_clinic_session.patients).not_to include( |
| 487 | + vaccinated_patient |
| 488 | + ) |
| 489 | + end |
| 490 | + end |
| 491 | + |
| 492 | + context "when a patient has already had the vaccine" do |
| 493 | + let!(:already_had_patient) { create(:patient, session:, programme:) } |
| 494 | + |
| 495 | + before do |
| 496 | + create( |
| 497 | + :vaccination_record, |
| 498 | + :not_administered, |
| 499 | + :already_had, |
| 500 | + patient: already_had_patient, |
| 501 | + programme: |
| 502 | + ) |
| 503 | + end |
| 504 | + |
| 505 | + it "doesn't add the patient to the generic clinic session" do |
| 506 | + expect(generic_clinic_session.patients).to be_empty |
| 507 | + close! |
| 508 | + expect(generic_clinic_session.patients).to be_empty |
| 509 | + end |
484 | 510 | end
|
485 | 511 | end
|
486 | 512 | end
|
|
0 commit comments