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
3 changes: 1 addition & 2 deletions app/views/sessions/manage_consent_reminders/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -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") %>
Expand Down Expand Up @@ -72,4 +71,4 @@
class: "nhsuk-button" %>
<% end %>
</div>
</div>
</div>
7 changes: 5 additions & 2 deletions db/seeds.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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|
Expand Down
16 changes: 8 additions & 8 deletions spec/components/app_patient_session_table_component_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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") }
Expand Down
6 changes: 3 additions & 3 deletions spec/features/cli_gias_check_import_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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]
)

Expand All @@ -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]
)

Expand All @@ -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
Expand Down
5 changes: 3 additions & 2 deletions spec/features/cli_stats_organisations_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
10 changes: 6 additions & 4 deletions spec/features/hpv_vaccination_offline_spec.rb
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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)
Expand Down Expand Up @@ -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
Expand Down
7 changes: 1 addition & 6 deletions spec/forms/triage_form_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions spec/lib/reports/careplus_exporter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions spec/lib/reports/systm_one_exporter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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:,
Expand Down
31 changes: 16 additions & 15 deletions spec/lib/stats/consents_by_school_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -92,18 +91,18 @@
described_class.new(
teams: [team],
programmes: [programme_flu],
academic_year: academic_year
academic_year:
)
end

let!(:flu_session) do
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
Expand All @@ -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
Expand Down Expand Up @@ -143,7 +142,7 @@
let!(:current_year_session) do
create(
:session,
team: team,
team:,
location: school,
programmes: [programme_flu],
academic_year: current_year
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
2 changes: 2 additions & 0 deletions spec/lib/status_generator/consent_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@
:refused,
patient:,
programme:,
academic_year: AcademicYear.current,
created_at: 1.day.ago,
submitted_at: 2.days.ago
)
Expand All @@ -137,6 +138,7 @@
:given,
patient:,
programme:,
academic_year: AcademicYear.current,
created_at: 2.days.ago,
submitted_at: 1.day.ago
)
Expand Down
2 changes: 2 additions & 0 deletions spec/lib/status_generator/registration_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 9 additions & 1 deletion spec/lib/vaccination_notification_criteria_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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]) }

Expand Down Expand Up @@ -53,6 +59,7 @@
:self_consent,
patient:,
programme:,
submitted_at: Date.new(2025, 1, 1),
notify_parents_on_vaccination: false
)
end
Expand All @@ -66,6 +73,7 @@
:consent,
patient:,
programme:,
submitted_at: Date.new(2025, 1, 1),
notify_parents_on_vaccination: nil
)
end
Expand Down
2 changes: 1 addition & 1 deletion spec/models/draft_vaccination_record_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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 }

Expand Down
4 changes: 3 additions & 1 deletion spec/models/immunisation_import_row_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions spec/models/immunisation_import_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
Expand Down Expand Up @@ -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" }
Expand Down
2 changes: 2 additions & 0 deletions spec/models/patient/consent_status_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@
:refused,
patient:,
programme:,
academic_year: AcademicYear.current,
created_at: 1.day.ago,
submitted_at: 2.days.ago
)
Expand All @@ -191,6 +192,7 @@
:given,
patient:,
programme:,
academic_year: AcademicYear.current,
created_at: 2.days.ago,
submitted_at: 1.day.ago
)
Expand Down
2 changes: 2 additions & 0 deletions spec/models/patient_session/registration_status_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions spec/models/pre_screening_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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:) }

Expand Down
2 changes: 1 addition & 1 deletion spec/models/session_date_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading
Loading