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
2 changes: 1 addition & 1 deletion app/jobs/enqueue_vaccinations_search_in_nhs_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def perform(sessions = nil)
Session
.includes(:session_dates)
.has_programmes([flu])
.where("sessions.send_invitations_at <= ?", 2.days.from_now)
.where("sessions.send_consent_requests_at <= ?", 2.days.from_now)
.where("session_dates.value >= ?", Time.zone.today)
.references(:session_dates)
end
Expand Down
4 changes: 4 additions & 0 deletions config/sidekiq.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@
cron: "0 9 * * *"
class: EnqueueClinicSessionInvitationsJob
description: Send school clinic invitation emails to parents
enqueue_vaccinations_search_in_nhs_job:
cron: "19 13 * * *"
class: EnqueueVaccinationsSearchInNHSJob
description: Find upcoming sessions and enqueue jobs to find vaccinations for patients in them
invalidate_self_consents:
cron: "0 2 * * *"
class: InvalidateSelfConsentsJob
Expand Down
20 changes: 12 additions & 8 deletions spec/jobs/enqueue_vaccinations_search_in_nhs_job_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,26 @@

before { allow(SearchVaccinationRecordsInNHSJob).to receive(:perform_bulk) }

let(:send_invitations_at) {}
let(:send_consent_requests_at) {}
let(:days_before_consent_reminders) { 7 }
let!(:session) do
create(
:session,
programmes: [flu],
academic_year: AcademicYear.pending,
dates:,
send_invitations_at:,
send_consent_requests_at:,
days_before_consent_reminders:,
team:,
location:
)
end

context "with a specific session" do
context "with an specific, unscheduled session" do
before { described_class.perform_now([session]) }

let(:dates) { [] }
let(:days_before_consent_reminders) { nil }

it { should have_received(:perform_bulk).once.with([[patient.id]]) }
end
Expand All @@ -39,7 +42,7 @@
before { described_class.perform_now }

let(:dates) { [7.days.from_now] }
let(:send_invitations_at) { 14.days.ago }
let(:send_consent_requests_at) { 14.days.ago }

it { should have_received(:perform_bulk).once.with([[patient.id]]) }

Expand All @@ -58,6 +61,7 @@
before { described_class.perform_now }

let(:dates) { [7.days.ago] }
let(:send_consent_requests_at) { 30.days.ago }

it { should_not have_received(:perform_bulk) }
end
Expand All @@ -68,7 +72,7 @@
} do
before { described_class.perform_now }

let(:send_invitations_at) { 28.days.ago }
let(:send_consent_requests_at) { 28.days.ago }
let(:dates) { [7.days.ago, 7.days.from_now] }

it { should have_received(:perform_bulk).exactly(:once) }
Expand All @@ -77,14 +81,14 @@
context "session with send_invitations_at in the future" do
before { described_class.perform_now }

let(:send_invitations_at) { 2.days.from_now }
let(:send_consent_requests_at) { 2.days.from_now }
let(:dates) { [17.days.from_now] }

it { should have_received(:perform_bulk).exactly(:once) }
end

context "session with send_invitations_at too far in the future" do
let(:send_invitations_at) { 3.days.from_now }
context "session with send_consent_requests_at too far in the future" do
let(:send_consent_requests_at) { 3.days.from_now }
let(:dates) { [17.days.from_now] }

it { should_not have_received(:perform_bulk) }
Expand Down