Skip to content

Commit 0111b1a

Browse files
authored
Merge pull request #5197 from nhsuk/attendance-record-date
Use attendance record date
2 parents ef0d122 + 2d0301d commit 0111b1a

2 files changed

Lines changed: 12 additions & 8 deletions

File tree

app/lib/status_generator/vaccination.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ def latest_date
6464
elsif latest_session_status_should_be_absent?
6565
[
6666
vaccination_records.map(&:performed_at).max&.to_date,
67-
attendance_record&.created_at&.to_date
67+
attendance_record&.date
6868
].compact.max
6969
else
7070
vaccination_records.map(&:performed_at).max&.to_date

spec/lib/status_generator/vaccination_spec.rb

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -516,10 +516,8 @@
516516
describe "#latest_date" do
517517
subject(:date) { generator.latest_date }
518518

519-
let(:performed_at) { 1.day.ago.to_date }
520-
let(:created_at) { 2.days.ago.to_date }
521-
522519
let(:programme) { CachedProgramme.hpv }
520+
let(:performed_at) { 1.day.ago.to_date }
523521

524522
context "with a vaccination administered" do
525523
before do
@@ -597,10 +595,16 @@
597595

598596
context "with absent from session attendance" do
599597
before do
600-
create(:attendance_record, :absent, patient:, session:, created_at:)
598+
create(
599+
:attendance_record,
600+
:absent,
601+
patient:,
602+
session:,
603+
date: performed_at.to_date
604+
)
601605
end
602606

603-
it { should eq(created_at) }
607+
it { should eq(performed_at.to_date) }
604608
end
605609

606610
context "with absent from both vaccination record and session attendance" do
@@ -623,7 +627,7 @@
623627
:absent,
624628
patient:,
625629
session:,
626-
created_at: later_date
630+
date: later_date
627631
)
628632
end
629633

@@ -646,7 +650,7 @@
646650
:absent,
647651
patient:,
648652
session:,
649-
created_at: earlier_date
653+
date: earlier_date
650654
)
651655
end
652656

0 commit comments

Comments
 (0)