diff --git a/app/views/sessions/manage_consent_reminders/show.html.erb b/app/views/sessions/manage_consent_reminders/show.html.erb index 78dc9162ec..b86eed8811 100644 --- a/app/views/sessions/manage_consent_reminders/show.html.erb +++ b/app/views/sessions/manage_consent_reminders/show.html.erb @@ -4,7 +4,6 @@ { text: t("sessions.index.title"), href: sessions_path }, { text: @session.location.name, href: session_path(@session) }, ]) %> - <%= render AppBacklinkComponent.new(session_path(@session), name: @session.location.name) %> <% end %> <%= h1 t(".title") %> @@ -72,4 +71,4 @@ class: "nhsuk-button" %> <% end %> - \ No newline at end of file + diff --git a/db/seeds.rb b/db/seeds.rb index dea2c32fbd..34822d7386 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -88,8 +88,11 @@ def create_session(user, team, programmes:, completed: false, year_groups: nil) session = FactoryBot.create(:session, date:, team:, programmes:, location:) - session.session_dates.create!(value: date - 1.day) - session.session_dates.create!(value: date + 1.day) + [date - 1.day, date + 1.day].each do |value| + if value.in?(session.academic_year.to_academic_year_date_range) + session.session_dates.create!(value:) + end + end programmes.each do |programme| year_groups.each do |year_group| diff --git a/spec/components/app_patient_session_table_component_spec.rb b/spec/components/app_patient_session_table_component_spec.rb index 4bd4f2f64e..7f8fc81d41 100644 --- a/spec/components/app_patient_session_table_component_spec.rb +++ b/spec/components/app_patient_session_table_component_spec.rb @@ -16,16 +16,16 @@ let(:location) { create(:school, name: "Waterloo Road", programmes:) } let(:session) do - create( - :session, - location:, - programmes:, - academic_year: 2024, - date: Date.new(2025, 1, 1) - ) + create(:session, location:, programmes:, date: Date.new(2025, 1, 1)) end - let(:patient_sessions) { create_list(:patient_session, 1, session:) } + # Can't use year_group here because we need an absolute date, not one + # relative to the current academic year. + let(:patient) { create(:patient, date_of_birth: Date.new(2011, 9, 1)) } + + let(:patient_sessions) do + create_list(:patient_session, 1, patient:, session:) + end it { should have_content("Location") } it { should have_content("Session dates") } diff --git a/spec/features/cli_gias_check_import_spec.rb b/spec/features/cli_gias_check_import_spec.rb index cf7048205d..83bca1abac 100644 --- a/spec/features/cli_gias_check_import_spec.rb +++ b/spec/features/cli_gias_check_import_spec.rb @@ -22,7 +22,7 @@ def and_there_are_schools_with_future_sessions create( :session, location: @school_with_future_session, - dates: [Date.tomorrow], + date: Date.tomorrow, programmes: [@programme] ) @@ -32,7 +32,7 @@ def and_there_are_schools_with_future_sessions create( :session, location: @school2_with_future_session, - dates: [Date.tomorrow], + date: Date.tomorrow, programmes: [@programme] ) @@ -42,7 +42,7 @@ def and_there_are_schools_with_future_sessions create( :session, location: @school_without_future_session, - dates: [Date.yesterday], + date: Date.yesterday, programmes: [@programme] ) end diff --git a/spec/features/cli_stats_organisations_spec.rb b/spec/features/cli_stats_organisations_spec.rb index d32f8cca25..4c33d250e2 100644 --- a/spec/features/cli_stats_organisations_spec.rb +++ b/spec/features/cli_stats_organisations_spec.rb @@ -112,8 +112,9 @@ def given_organisation_has_complete_data_with_filters create( :session, team: @team_a, - academic_year: (Date.current.year - 1), - programmes: [programme_flu] + academic_year: AcademicYear.current - 1, + programmes: [programme_flu], + date: (AcademicYear.current - 1).to_academic_year_date_range.end ) patient_year_8 = create(:patient, team: @team_a, year_group: 8) diff --git a/spec/features/hpv_vaccination_offline_spec.rb b/spec/features/hpv_vaccination_offline_spec.rb index 8703966734..fb874abc10 100644 --- a/spec/features/hpv_vaccination_offline_spec.rb +++ b/spec/features/hpv_vaccination_offline_spec.rb @@ -1,9 +1,11 @@ # frozen_string_literal: true describe "HPV vaccination" do - scenario "Download spreadsheet, record offline at a school session, upload vaccination outcomes back into Mavis" do - travel_to(Time.zone.local(2024, 2, 1, 12, 0, 0)) + around do |example| + travel_to(Time.zone.local(2024, 2, 1, 12)) { example.run } + end + scenario "Download spreadsheet, record offline at a school session, upload vaccination outcomes back into Mavis" do stub_pds_get_nhs_number_to_return_a_patient given_an_hpv_programme_is_underway @@ -22,8 +24,6 @@ end scenario "Download spreadsheet, record offline at a clinic, upload vaccination outcomes back into Mavis" do - travel_to(Time.zone.local(2024, 2, 1, 12, 0, 0)) - stub_pds_get_nhs_number_to_return_a_patient given_an_hpv_programme_is_underway(clinic: true) @@ -355,6 +355,8 @@ def when_i_record_vaccination_outcomes_to_the_spreadsheet_and_export_it_to_csv end def and_i_upload_the_modified_csv_file + travel 1.minute + visit "/" click_on "Import", match: :first diff --git a/spec/forms/triage_form_spec.rb b/spec/forms/triage_form_spec.rb index 28ea502cd6..0933b466ac 100644 --- a/spec/forms/triage_form_spec.rb +++ b/spec/forms/triage_form_spec.rb @@ -16,12 +16,7 @@ it { should_not validate_presence_of(:notes) } it { should_not validate_presence_of(:vaccine_methods) } it { should validate_length_of(:notes).is_at_most(1000) } - - it do - expect(form).to validate_inclusion_of(:add_psd).in_array( - [true, false] - ).allow_nil - end + it { should allow_values(true, false).for(:add_psd) } end describe "when the patient is safe to vaccinate for HPV" do diff --git a/spec/lib/reports/careplus_exporter_spec.rb b/spec/lib/reports/careplus_exporter_spec.rb index 629eaf7d7c..9866d211f5 100644 --- a/spec/lib/reports/careplus_exporter_spec.rb +++ b/spec/lib/reports/careplus_exporter_spec.rb @@ -11,6 +11,8 @@ ) end + around { |example| travel_to(Date.new(2025, 8, 31)) { example.run } } + let(:academic_year) { AcademicYear.current } shared_examples "generates a report" do diff --git a/spec/lib/reports/systm_one_exporter_spec.rb b/spec/lib/reports/systm_one_exporter_spec.rb index 693e976394..72d901bd61 100644 --- a/spec/lib/reports/systm_one_exporter_spec.rb +++ b/spec/lib/reports/systm_one_exporter_spec.rb @@ -5,6 +5,8 @@ before { vaccination_record } + around { |example| travel_to(Date.new(2025, 8, 31)) { example.run } } + let(:csv) do described_class.call( team:, diff --git a/spec/lib/stats/consents_by_school_spec.rb b/spec/lib/stats/consents_by_school_spec.rb index d2b486874d..862cb89968 100644 --- a/spec/lib/stats/consents_by_school_spec.rb +++ b/spec/lib/stats/consents_by_school_spec.rb @@ -31,21 +31,20 @@ team: team, location: school, programmes: [programme_flu], - academic_year: academic_year, + academic_year:, send_consent_requests_at: 10.days.ago ) end - let!(:patient) { create(:patient, team: team) } - let(:patient_session) do - create(:patient_session, session: session, patient: patient) - end + let!(:patient) { create(:patient, team:) } + let(:patient_session) { create(:patient_session, session:, patient:) } let(:consent) do create( :consent, :given, - patient: patient, + patient:, + academic_year:, programme: programme_flu, submitted_at: 8.days.ago, created_at: 8.days.ago @@ -92,7 +91,7 @@ described_class.new( teams: [team], programmes: [programme_flu], - academic_year: academic_year + academic_year: ) end @@ -100,10 +99,10 @@ create( :session, date: Date.new(AcademicYear.current, 12, 15), - team: team, + team:, location: school, programmes: [programme_flu], - academic_year: academic_year, + academic_year:, send_consent_requests_at: Date.new(AcademicYear.current, 12, 1) ) end @@ -112,10 +111,10 @@ create( :session, date: Date.new(AcademicYear.current, 11, 15), - team: team, + team:, location: school, programmes: [programme_hpv], - academic_year: academic_year, + academic_year:, send_consent_requests_at: Date.new(AcademicYear.current, 11, 1) ) end @@ -143,7 +142,7 @@ let!(:current_year_session) do create( :session, - team: team, + team:, location: school, programmes: [programme_flu], academic_year: current_year @@ -154,7 +153,7 @@ create( :session, date: Date.new(AcademicYear.current - 1, 12, 15), - team: team, + team:, location: school, programmes: [programme_flu], academic_year: previous_year @@ -192,7 +191,8 @@ create( :consent, :given, - patient: patient, + patient:, + academic_year:, programme: programme_flu, submitted_at: 8.days.ago, created_at: 8.days.ago @@ -203,7 +203,8 @@ create( :consent, :given, - patient: patient, + patient:, + academic_year:, programme: programme_hpv, submitted_at: 6.days.ago, created_at: 6.days.ago diff --git a/spec/lib/status_generator/consent_spec.rb b/spec/lib/status_generator/consent_spec.rb index bfe106d243..5661ebb294 100644 --- a/spec/lib/status_generator/consent_spec.rb +++ b/spec/lib/status_generator/consent_spec.rb @@ -129,6 +129,7 @@ :refused, patient:, programme:, + academic_year: AcademicYear.current, created_at: 1.day.ago, submitted_at: 2.days.ago ) @@ -137,6 +138,7 @@ :given, patient:, programme:, + academic_year: AcademicYear.current, created_at: 2.days.ago, submitted_at: 1.day.ago ) diff --git a/spec/lib/status_generator/registration_spec.rb b/spec/lib/status_generator/registration_spec.rb index a21a52516e..a6aa1b61e7 100644 --- a/spec/lib/status_generator/registration_spec.rb +++ b/spec/lib/status_generator/registration_spec.rb @@ -12,6 +12,8 @@ ) end + around { |example| travel_to(Date.new(2025, 8, 31)) { example.run } } + let(:programmes) do [create(:programme, :menacwy), create(:programme, :td_ipv)] end diff --git a/spec/lib/vaccination_notification_criteria_spec.rb b/spec/lib/vaccination_notification_criteria_spec.rb index 5c0fa6e57c..4a92f709ce 100644 --- a/spec/lib/vaccination_notification_criteria_spec.rb +++ b/spec/lib/vaccination_notification_criteria_spec.rb @@ -7,7 +7,13 @@ let(:programme) { build(:programme) } let(:patient) { create(:patient) } let(:vaccination_record) do - build(:vaccination_record, patient:, programme:, session:) + build( + :vaccination_record, + patient:, + programme:, + session:, + performed_at: Date.new(2025, 2, 1) + ) end let(:session) { create(:session, programmes: [programme]) } @@ -53,6 +59,7 @@ :self_consent, patient:, programme:, + submitted_at: Date.new(2025, 1, 1), notify_parents_on_vaccination: false ) end @@ -66,6 +73,7 @@ :consent, patient:, programme:, + submitted_at: Date.new(2025, 1, 1), notify_parents_on_vaccination: nil ) end diff --git a/spec/models/draft_vaccination_record_spec.rb b/spec/models/draft_vaccination_record_spec.rb index dc67d4c4b8..0f48f7ca9e 100644 --- a/spec/models/draft_vaccination_record_spec.rb +++ b/spec/models/draft_vaccination_record_spec.rb @@ -70,7 +70,7 @@ ) end - around { |example| freeze_time { example.run } } + around { |example| travel_to(Date.new(2025, 8, 31)) { example.run } } before { draft_vaccination_record.wizard_step = :date_and_time } diff --git a/spec/models/immunisation_import_row_spec.rb b/spec/models/immunisation_import_row_spec.rb index 43e4c992c4..f21e6212a1 100644 --- a/spec/models/immunisation_import_row_spec.rb +++ b/spec/models/immunisation_import_row_spec.rb @@ -299,9 +299,11 @@ before { immunisation_import_row.valid? } context "when importing for an existing session" do + around { |example| travel_to(Date.new(2025, 9, 1)) { example.run } } + let(:data) do { - "DATE_OF_VACCINATION" => "#{AcademicYear.current}0901", + "DATE_OF_VACCINATION" => "20250902", "SESSION_ID" => session.id.to_s } end diff --git a/spec/models/immunisation_import_spec.rb b/spec/models/immunisation_import_spec.rb index 1bcd38ffd0..2867299171 100644 --- a/spec/models/immunisation_import_spec.rb +++ b/spec/models/immunisation_import_spec.rb @@ -78,6 +78,8 @@ describe "#parse_rows!" do before { immunisation_import.parse_rows! } + around { |example| travel_to(Date.new(2025, 8, 1)) { example.run } } + context "with valid Flu rows" do let(:programmes) { [create(:programme, :flu_all_vaccines)] } let(:file) { "valid_flu.csv" } @@ -128,6 +130,8 @@ describe "#process!" do subject(:process!) { immunisation_import.process! } + around { |example| travel_to(Date.new(2025, 8, 1)) { example.run } } + context "with valid Flu rows" do let(:programmes) { [create(:programme, :flu_all_vaccines)] } let(:file) { "valid_flu.csv" } diff --git a/spec/models/patient/consent_status_spec.rb b/spec/models/patient/consent_status_spec.rb index d5b87efeb9..064d454447 100644 --- a/spec/models/patient/consent_status_spec.rb +++ b/spec/models/patient/consent_status_spec.rb @@ -183,6 +183,7 @@ :refused, patient:, programme:, + academic_year: AcademicYear.current, created_at: 1.day.ago, submitted_at: 2.days.ago ) @@ -191,6 +192,7 @@ :given, patient:, programme:, + academic_year: AcademicYear.current, created_at: 2.days.ago, submitted_at: 1.day.ago ) diff --git a/spec/models/patient_session/registration_status_spec.rb b/spec/models/patient_session/registration_status_spec.rb index 40f8f1c4a3..e14021b812 100644 --- a/spec/models/patient_session/registration_status_spec.rb +++ b/spec/models/patient_session/registration_status_spec.rb @@ -22,6 +22,8 @@ build(:patient_session_registration_status, patient_session:) end + around { |example| travel_to(Date.new(2025, 8, 31)) { example.run } } + let(:programmes) do [create(:programme, :menacwy), create(:programme, :td_ipv)] end diff --git a/spec/models/pre_screening_spec.rb b/spec/models/pre_screening_spec.rb index 82c6c812e2..620067a166 100644 --- a/spec/models/pre_screening_spec.rb +++ b/spec/models/pre_screening_spec.rb @@ -47,6 +47,8 @@ end context "with an instance for yesterday" do + around { |example| travel_to(Date.new(2025, 8, 31)) { example.run } } + let(:session_date) { create(:session_date, value: Date.yesterday) } let(:pre_screening) { create(:pre_screening, session_date:) } diff --git a/spec/models/session_date_spec.rb b/spec/models/session_date_spec.rb index 70bc81bab2..d4ae33e676 100644 --- a/spec/models/session_date_spec.rb +++ b/spec/models/session_date_spec.rb @@ -19,7 +19,7 @@ describe SessionDate do subject(:session_date) { build(:session_date, session:, value:) } - let(:session) { create(:session, academic_year: 2024) } + let(:session) { create(:session, :unscheduled, academic_year: 2024) } let(:value) { Date.current } describe "validations" do diff --git a/spec/policies/session_attendance_policy_spec.rb b/spec/policies/session_attendance_policy_spec.rb index fb947bee12..47fb584ee9 100644 --- a/spec/policies/session_attendance_policy_spec.rb +++ b/spec/policies/session_attendance_policy_spec.rb @@ -59,6 +59,8 @@ context "with session attendance and both vaccination records from a different date" do let(:session_attendance) { build(:session_attendance, patient_session:) } + around { |example| travel_to(Date.new(2025, 8, 31)) { example.run } } + before do programmes.each do |programme| create(