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
8 changes: 7 additions & 1 deletion app/jobs/patients_aged_out_of_school_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,13 @@ def perform
next if school.year_groups.include?(year_group)

team = school.team
SchoolMove.new(patient:, home_educated: false, team:).confirm!

SchoolMove.new(
patient:,
home_educated: false,
team:,
academic_year:
).confirm!
end
end
end
12 changes: 12 additions & 0 deletions spec/jobs/patients_aged_out_of_school_job_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
let(:date_of_birth) { Date.new(2008, 1, 1) }

let!(:patient) { create(:patient, school:, date_of_birth:) }
let!(:clinic_session) do
team.generic_clinic_session(academic_year: AcademicYear.pending)
end

context "on the last day of July" do
let(:today) { Date.new(2024, 7, 31) }
Expand All @@ -28,6 +31,10 @@
it "doesn't move the patient to unknown school" do
expect { perform }.not_to(change { patient.reload.school })
end

it "doesn't add the patient to the clinic session" do
expect { perform }.not_to(change { patient.sessions.count })
end
end

context "on the first day of August" do
Expand All @@ -49,5 +56,10 @@
it "moves the patient to unknown school" do
expect { perform }.to change { patient.reload.school }.to(nil)
end

it "adds the patient to the clinic session" do
expect { perform }.to change { patient.sessions.count }.by(1)
expect(patient.sessions).to include(clinic_session)
end
end
end