Skip to content

Commit 7403bca

Browse files
committed
Show academic year during preparation period
If we're in the preparation period, it's not always clear which academic year is being used to display a year group, therefore we should always show the academic year during the preparation period.
1 parent 8b33f9b commit 7403bca

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

app/helpers/patients_helper.rb

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,15 @@ def patient_year_group(patient, academic_year:)
4141
patient.registration_academic_year == academic_year &&
4242
patient.registration.present?
4343

44-
str = str.dup if include_registration
44+
include_academic_year =
45+
academic_year != AcademicYear.current ||
46+
AcademicYear.current != AcademicYear.pending
47+
48+
str = str.dup if include_registration || include_academic_year
4549

4650
str << ", #{patient.registration}" if include_registration
4751

48-
if academic_year != AcademicYear.current
52+
if include_academic_year
4953
str << " (#{format_academic_year(academic_year)} academic year)"
5054
end
5155

spec/helpers/patients_helper_spec.rb

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,5 +120,21 @@
120120
it { should eq("Year 10 (2024 to 2025 academic year)") }
121121
end
122122
end
123+
124+
context "during the preparation period" do
125+
let(:today) { Date.new(2024, 8, 1) }
126+
let(:academic_year) { today.academic_year }
127+
128+
it { should eq("Year 9 (2023 to 2024 academic year)") }
129+
130+
context "with a registration" do
131+
before do
132+
patient.registration = "9AB"
133+
patient.registration_academic_year = today.academic_year
134+
end
135+
136+
it { should eq("Year 9, 9AB (2023 to 2024 academic year)") }
137+
end
138+
end
123139
end
124140
end

0 commit comments

Comments
 (0)