|
14 | 14 | let(:disease_types) { programmes.flat_map(&:disease_types).uniq.presence } |
15 | 15 | let(:programme_types) { programmes.map(&:type) } |
16 | 16 | let(:team) { create(:team, programmes:) } |
17 | | - let(:session) { create(:session, location:, programmes:, team:) } |
| 17 | + let(:send_consent_requests_at) { nil } |
| 18 | + let(:session) do |
| 19 | + create(:session, location:, programmes:, team:, send_consent_requests_at:) |
| 20 | + end |
18 | 21 | let(:team_location) { session.team_location } |
19 | 22 |
|
20 | 23 | context "with a session" do |
|
40 | 43 | expect(consent_notification.sent_at).to eq(today) |
41 | 44 | end |
42 | 45 |
|
| 46 | + context "when the consent request was scheduled for the future" do |
| 47 | + let(:send_consent_requests_at) { today + 1.day } |
| 48 | + |
| 49 | + it "updates the programme status after sending the request" do |
| 50 | + travel_to(today) do |
| 51 | + PatientStatusUpdater.call(patient:) |
| 52 | + |
| 53 | + expect( |
| 54 | + patient.programme_status( |
| 55 | + programmes.first, |
| 56 | + academic_year: session.academic_year |
| 57 | + ) |
| 58 | + ).to be_needs_consent_request_scheduled |
| 59 | + |
| 60 | + notifier.send_consent_request(programmes, session:, sent_by:) |
| 61 | + |
| 62 | + expect(PatientStatusUpdaterJob).to have_enqueued_sidekiq_job( |
| 63 | + patient.id |
| 64 | + ) |
| 65 | + |
| 66 | + PatientStatusUpdaterJob.drain |
| 67 | + |
| 68 | + expect( |
| 69 | + patient.programme_status( |
| 70 | + programmes.first, |
| 71 | + academic_year: session.academic_year |
| 72 | + ).reload |
| 73 | + ).to be_needs_consent_no_response |
| 74 | + end |
| 75 | + end |
| 76 | + end |
| 77 | + |
43 | 78 | it "enqueues an email per parent" do |
44 | 79 | expect { send_consent_request }.to have_delivered_email( |
45 | 80 | :consent_school_request_hpv |
|
0 commit comments