diff --git a/Dockerfile b/Dockerfile index 6c4c8bf682..5cd7c13c1d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -74,12 +74,15 @@ COPY db ${APP_HOME}/db COPY app ${APP_HOME}/app COPY spec ${APP_HOME}/spec +# Not actual SECRET_KEY_BASE and is randomly generated just for this task + RUN DFE_SIGN_IN_API_CLIENT_ID= \ DFE_SIGN_IN_API_SECRET= \ DFE_SIGN_IN_API_ENDPOINT= \ ADMIN_ALLOWED_IPS= \ ENVIRONMENT_NAME= \ SUPPRESS_DFE_ANALYTICS_INIT= \ + SECRET_KEY_BASE="1d40d61e24db3cd4282716c45890c33b5be4ac99eee12ddfe758a01ad03d3206b5888911211ea9e29eee891c76e7011e8eae9f0c868d500575ea3b18749f31f1" \ bundle exec rake assets:precompile RUN chown -hR appuser:appgroup ${APP_HOME} diff --git a/Gemfile b/Gemfile index 5f5f050666..996fbf5a06 100644 --- a/Gemfile +++ b/Gemfile @@ -4,7 +4,7 @@ git_source(:github) { |repo| "https://github.com/#{repo}.git" } ruby "3.3.5" # Bundle edge Rails instead: gem 'rails', github: 'rails/rails' -gem "rails", "~> 7.0.8" +gem "rails", "~> 7.1.5" # Use postgresql as the database for Active Record gem "pg", ">= 0.18", "< 2.0" # Use Puma as the app server diff --git a/Gemfile.lock b/Gemfile.lock index 2c1815d7ed..6ddfe12773 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -19,74 +19,86 @@ GIT GEM remote: https://rubygems.org/ specs: - actioncable (7.0.8.5) - actionpack (= 7.0.8.5) - activesupport (= 7.0.8.5) + actioncable (7.1.5) + actionpack (= 7.1.5) + activesupport (= 7.1.5) nio4r (~> 2.0) websocket-driver (>= 0.6.1) - actionmailbox (7.0.8.5) - actionpack (= 7.0.8.5) - activejob (= 7.0.8.5) - activerecord (= 7.0.8.5) - activestorage (= 7.0.8.5) - activesupport (= 7.0.8.5) + zeitwerk (~> 2.6) + actionmailbox (7.1.5) + actionpack (= 7.1.5) + activejob (= 7.1.5) + activerecord (= 7.1.5) + activestorage (= 7.1.5) + activesupport (= 7.1.5) mail (>= 2.7.1) net-imap net-pop net-smtp - actionmailer (7.0.8.5) - actionpack (= 7.0.8.5) - actionview (= 7.0.8.5) - activejob (= 7.0.8.5) - activesupport (= 7.0.8.5) + actionmailer (7.1.5) + actionpack (= 7.1.5) + actionview (= 7.1.5) + activejob (= 7.1.5) + activesupport (= 7.1.5) mail (~> 2.5, >= 2.5.4) net-imap net-pop net-smtp - rails-dom-testing (~> 2.0) - actionpack (7.0.8.5) - actionview (= 7.0.8.5) - activesupport (= 7.0.8.5) - rack (~> 2.0, >= 2.2.4) + rails-dom-testing (~> 2.2) + actionpack (7.1.5) + actionview (= 7.1.5) + activesupport (= 7.1.5) + nokogiri (>= 1.8.5) + racc + rack (>= 2.2.4) + rack-session (>= 1.0.1) rack-test (>= 0.6.3) - rails-dom-testing (~> 2.0) - rails-html-sanitizer (~> 1.0, >= 1.2.0) - actiontext (7.0.8.5) - actionpack (= 7.0.8.5) - activerecord (= 7.0.8.5) - activestorage (= 7.0.8.5) - activesupport (= 7.0.8.5) + rails-dom-testing (~> 2.2) + rails-html-sanitizer (~> 1.6) + actiontext (7.1.5) + actionpack (= 7.1.5) + activerecord (= 7.1.5) + activestorage (= 7.1.5) + activesupport (= 7.1.5) globalid (>= 0.6.0) nokogiri (>= 1.8.5) - actionview (7.0.8.5) - activesupport (= 7.0.8.5) + actionview (7.1.5) + activesupport (= 7.1.5) builder (~> 3.1) - erubi (~> 1.4) - rails-dom-testing (~> 2.0) - rails-html-sanitizer (~> 1.1, >= 1.2.0) - activejob (7.0.8.5) - activesupport (= 7.0.8.5) + erubi (~> 1.11) + rails-dom-testing (~> 2.2) + rails-html-sanitizer (~> 1.6) + activejob (7.1.5) + activesupport (= 7.1.5) globalid (>= 0.3.6) - activemodel (7.0.8.5) - activesupport (= 7.0.8.5) - activerecord (7.0.8.5) - activemodel (= 7.0.8.5) - activesupport (= 7.0.8.5) + activemodel (7.1.5) + activesupport (= 7.1.5) + activerecord (7.1.5) + activemodel (= 7.1.5) + activesupport (= 7.1.5) + timeout (>= 0.4.0) activerecord-copy (1.1.0) activerecord (>= 3.1) activerecord-nulldb-adapter (1.0.1) activerecord (>= 5.2.0, < 7.2) - activestorage (7.0.8.5) - actionpack (= 7.0.8.5) - activejob (= 7.0.8.5) - activerecord (= 7.0.8.5) - activesupport (= 7.0.8.5) + activestorage (7.1.5) + actionpack (= 7.1.5) + activejob (= 7.1.5) + activerecord (= 7.1.5) + activesupport (= 7.1.5) marcel (~> 1.0) - mini_mime (>= 1.1.0) - activesupport (7.0.8.5) + activesupport (7.1.5) + base64 + benchmark (>= 0.3) + bigdecimal concurrent-ruby (~> 1.0, >= 1.0.2) + connection_pool (>= 2.2.5) + drb i18n (>= 1.6, < 2) + logger (>= 1.4.2) minitest (>= 5.1) + mutex_m + securerandom (>= 0.3) tzinfo (~> 2.0) addressable (2.8.7) public_suffix (>= 2.0.2, < 7.0) @@ -94,6 +106,7 @@ GEM ast (2.4.2) attr_required (1.0.1) base64 (0.2.0) + benchmark (0.4.0) bigdecimal (3.1.8) bindata (2.5.0) bindex (0.8.1) @@ -117,6 +130,7 @@ GEM childprocess (5.0.0) coderay (1.1.3) concurrent-ruby (1.3.4) + connection_pool (2.4.1) crack (1.0.0) bigdecimal rexml @@ -138,6 +152,7 @@ GEM dotenv-rails (3.1.2) dotenv (= 3.1.2) railties (>= 6.1) + drb (2.2.1) erubi (1.13.0) et-orbi (1.2.11) tzinfo @@ -234,6 +249,10 @@ GEM httpclient (2.8.3) i18n (1.14.6) concurrent-ruby (~> 1.0) + io-console (0.7.2) + irb (1.14.1) + rdoc (>= 4.0.0) + reline (>= 0.4.2) jbuilder (2.13.0) actionview (>= 5.0.0) activesupport (>= 5.0.0) @@ -273,7 +292,7 @@ GEM matrix (0.4.2) method_source (1.1.0) mini_mime (1.1.5) - mini_portile2 (2.8.7) + mini_portile2 (2.8.8) minitest (5.25.1) msgpack (1.7.2) multi_json (1.15.0) @@ -336,12 +355,14 @@ GEM pry (0.14.2) coderay (~> 1.1) method_source (~> 1.0) + psych (5.2.0) + stringio public_suffix (6.0.1) puma (6.4.3) nio4r (~> 2.0) raabro (1.4.0) racc (1.8.1) - rack (2.2.10) + rack (3.1.8) rack-mini-profiler (3.3.1) rack (>= 1.2.0) rack-oauth2 (1.21.3) @@ -350,28 +371,33 @@ GEM httpclient json-jwt (>= 1.11.0) rack (>= 2.1.0) - rack-protection (3.2.0) + rack-protection (4.1.0) base64 (>= 0.1.0) - rack (~> 2.2, >= 2.2.4) + logger (>= 1.6.0) + rack (>= 3.0.0, < 4) + rack-session (2.0.0) + rack (>= 3.0.0) rack-test (2.1.0) rack (>= 1.3) rack_session_access (0.2.0) builder (>= 2.0.0) rack (>= 1.0.0) - rails (7.0.8.5) - actioncable (= 7.0.8.5) - actionmailbox (= 7.0.8.5) - actionmailer (= 7.0.8.5) - actionpack (= 7.0.8.5) - actiontext (= 7.0.8.5) - actionview (= 7.0.8.5) - activejob (= 7.0.8.5) - activemodel (= 7.0.8.5) - activerecord (= 7.0.8.5) - activestorage (= 7.0.8.5) - activesupport (= 7.0.8.5) + rackup (2.2.1) + rack (>= 3) + rails (7.1.5) + actioncable (= 7.1.5) + actionmailbox (= 7.1.5) + actionmailer (= 7.1.5) + actionpack (= 7.1.5) + actiontext (= 7.1.5) + actionview (= 7.1.5) + activejob (= 7.1.5) + activemodel (= 7.1.5) + activerecord (= 7.1.5) + activestorage (= 7.1.5) + activesupport (= 7.1.5) bundler (>= 1.15.0) - railties (= 7.0.8.5) + railties (= 7.1.5) rails-dom-testing (2.2.0) activesupport (>= 5.0.0) minitest @@ -383,19 +409,24 @@ GEM rack railties (>= 5.1) semantic_logger (~> 4.13) - railties (7.0.8.5) - actionpack (= 7.0.8.5) - activesupport (= 7.0.8.5) - method_source + railties (7.1.5) + actionpack (= 7.1.5) + activesupport (= 7.1.5) + irb + rackup (>= 1.0.0) rake (>= 12.2) - thor (~> 1.0) - zeitwerk (~> 2.5) + thor (~> 1.0, >= 1.2.2) + zeitwerk (~> 2.6) rainbow (3.1.1) rake (13.2.1) rb-fsevent (0.11.2) rb-inotify (0.10.1) ffi (~> 1.0) + rdoc (6.8.1) + psych (>= 4.0.0) regexp_parser (2.9.2) + reline (0.5.11) + io-console (~> 0.5) representable (3.2.0) declarative (< 0.1.0) trailblazer-option (>= 0.1.1, < 0.2.0) @@ -410,12 +441,12 @@ GEM rspec-core (~> 3.13.0) rspec-expectations (~> 3.13.0) rspec-mocks (~> 3.13.0) - rspec-core (3.13.0) + rspec-core (3.13.2) rspec-support (~> 3.13.0) - rspec-expectations (3.13.1) + rspec-expectations (3.13.3) diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.13.0) - rspec-mocks (3.13.1) + rspec-mocks (3.13.2) diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.13.0) rspec-rails (6.1.3) @@ -458,6 +489,7 @@ GEM sprockets (> 3.0) sprockets-rails tilt + securerandom (0.3.2) selenium-webdriver (4.25.0) base64 (~> 0.2) logger (~> 1.4) @@ -502,6 +534,7 @@ GEM standard-performance (1.4.0) lint_roller (~> 1.1) rubocop-performance (~> 1.21.0) + stringio (3.1.2) swd (1.3.0) activesupport (>= 3) attr_required (>= 0.0.5) @@ -554,9 +587,9 @@ GEM zeitwerk (2.6.16) PLATFORMS + arm64-darwin-23 ruby x86_64-darwin-21 - x86_64-darwin-23 x86_64-linux DEPENDENCIES @@ -596,7 +629,7 @@ DEPENDENCIES puma (~> 6.4) rack-mini-profiler rack_session_access - rails (~> 7.0.8) + rails (~> 7.1.5) rails_semantic_logger rollbar rotp diff --git a/app/models/amendment.rb b/app/models/amendment.rb index e73a745997..a9b86feb03 100644 --- a/app/models/amendment.rb +++ b/app/models/amendment.rb @@ -10,7 +10,7 @@ class Amendment < ApplicationRecord belongs_to :claim belongs_to :created_by, class_name: "DfeSignIn::User" - serialize :claim_changes, Hash + serialize :claim_changes, type: Hash validates :claim_changes, presence: {message: "To amend the claim you must change at least one value"} validates :notes, presence: {message: "Enter a message to explain why you are making this amendment"} diff --git a/app/views/admin/tasks/_form.html.erb b/app/views/admin/tasks/_form.html.erb index affaf38a8a..06b982e594 100644 --- a/app/views/admin/tasks/_form.html.erb +++ b/app/views/admin/tasks/_form.html.erb @@ -12,10 +12,7 @@ I18n.t( "#{translation}.body.match.#{f.object.claim_verifier_match.presence || 'nil'}", default: nil, - link: link_to( - I18n.t("#{translation}.notes"), - admin_claim_notes_path(@claim) - ) + link: link_to("Notes", admin_claim_notes_path(@claim)) )&.html_safe.tap do |translation| %> <% break unless translation %> diff --git a/config/environments/test.rb b/config/environments/test.rb index 77c9ccbd78..a92b501287 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -28,7 +28,7 @@ config.cache_store = :null_store # Raise exceptions instead of rendering exception templates. - config.action_dispatch.show_exceptions = false + config.action_dispatch.show_exceptions = :none # Disable request forgery protection in test environment. config.action_controller.allow_forgery_protection = false diff --git a/config/locales/en.yml b/config/locales/en.yml index c006566773..c909269a1a 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -369,6 +369,10 @@ en: qualification_details: errors: qualifications_details_check: "Select yes if your qualification details are correct" + email_verification: + errors: + one_time_password: + invalid: An error occured while validating the passcode, please try generating a new one journey_name: "Teachers: claim back your student loan repayments" policy_short_name: "Student Loans" policy_acronym: "TSLR" diff --git a/config/routes.rb b/config/routes.rb index 87614e70ff..54b3fa1b29 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -29,7 +29,7 @@ def initialize(journey) end def matches?(request) - request["journey"] == journey::ROUTING_NAME && journey.slug_sequence::SLUGS.include?(request["slug"]) + request.path_parameters[:journey] == journey::ROUTING_NAME && journey.slug_sequence::SLUGS.include?(request.path_parameters[:slug]) end } diff --git a/lib/tasks/default.rake b/lib/tasks/default.rake index 9687fc447f..4fc8c2a194 100644 --- a/lib/tasks/default.rake +++ b/lib/tasks/default.rake @@ -5,7 +5,11 @@ db_namespace = namespace(:db) { task setup_or_migrate: :load_config do ActiveRecord::Base.configurations.configs_for(env_name: Rails.env).each do |db_config| ActiveRecord::Base.establish_connection(db_config.configuration_hash) - if ActiveRecord::SchemaMigration.table_exists? + + connection = ActiveRecord::Base.connection + schema_migration = ActiveRecord::SchemaMigration.new(connection) + + if schema_migration.table_exists? db_namespace["migrate"].invoke else db_namespace["setup"].invoke diff --git a/spec/features/combined_teacher_claim_journey_with_teacher_id_spec.rb b/spec/features/combined_teacher_claim_journey_with_teacher_id_spec.rb index 34ee065a45..e916b675eb 100644 --- a/spec/features/combined_teacher_claim_journey_with_teacher_id_spec.rb +++ b/spec/features/combined_teacher_claim_journey_with_teacher_id_spec.rb @@ -60,7 +60,7 @@ expect(page).not_to have_text(I18n.t("additional_payments.forms.qualification.questions.which_route")) expect(page).not_to have_text(I18n.t("additional_payments.forms.eligible_itt_subject.questions.which_subject", qualification: "undergraduate initial teacher training (ITT)")) expect(page).not_to have_text(I18n.t("additional_payments.questions.itt_academic_year.qualification.undergraduate_itt")) - expect(page).not_to have_text(I18n.t("additional_payments.questions.eligible_degree_subject")) + expect(page).not_to have_text(I18n.t("additional_payments.forms.eligible_degree_subject.questions.eligible_degree_subject")) # Go back to the qualification details page click_link "Back" @@ -105,7 +105,7 @@ expect(page).to have_text(I18n.t("additional_payments.forms.qualification.questions.which_route")) expect(page).to have_text(I18n.t("additional_payments.forms.eligible_itt_subject.questions.single_subject", qualification: "undergraduate initial teacher training (ITT)", subject: "mathematics")) expect(page).to have_text(I18n.t("additional_payments.questions.itt_academic_year.qualification.undergraduate_itt")) - expect(page).not_to have_text(I18n.t("additional_payments.questions.eligible_degree_subject")) + expect(page).not_to have_text(I18n.t("additional_payments.forms.eligible_degree_subject.questions.eligible_degree_subject")) click_on("Continue") @@ -180,7 +180,7 @@ navigate_until_performance_related_questions(expect_induction_question: true) # Qualification pages are not skipped - expect(page).not_to have_text(I18n.t("additional_payments.questions.check_and_confirm_qualification_details")) + expect(page).not_to have_text(I18n.t("questions.check_and_confirm_qualification_details")) # - What route into teaching did you take? expect(page).to have_text(I18n.t("additional_payments.forms.qualification.questions.which_route")) @@ -206,7 +206,7 @@ expect(page).to have_text(I18n.t("additional_payments.forms.qualification.questions.which_route")) expect(page).to have_text(I18n.t("additional_payments.forms.eligible_itt_subject.questions.single_subject", qualification: "undergraduate initial teacher training (ITT)", subject: "mathematics")) expect(page).to have_text(I18n.t("additional_payments.questions.itt_academic_year.qualification.undergraduate_itt")) - expect(page).not_to have_text(I18n.t("additional_payments.questions.eligible_degree_subject")) + expect(page).not_to have_text(I18n.t("additional_payments.forms.eligible_degree_subject.questions.eligible_degree_subject")) end scenario "When user is logged in with Teacher ID and NINO is not supplied" do @@ -286,7 +286,7 @@ expect(page).not_to have_text(I18n.t("additional_payments.forms.qualification.questions.which_route")) expect(page).not_to have_text(I18n.t("additional_payments.forms.eligible_itt_subject.questions.which_subject", qualification: "undergraduate initial teacher training (ITT)")) expect(page).to have_text(I18n.t("additional_payments.questions.itt_academic_year.qualification.undergraduate_itt")) - expect(page).not_to have_text(I18n.t("additional_payments.questions.eligible_degree_subject")) + expect(page).not_to have_text(I18n.t("additional_payments.forms.eligible_degree_subject.questions.eligible_degree_subject")) end scenario "When user is logged in with Teacher ID and the ITT subject is ineligible" do diff --git a/spec/features/early_career_payments/early_career_payments_claim_spec.rb b/spec/features/early_career_payments/early_career_payments_claim_spec.rb index 75029a554b..b5727f4f7a 100644 --- a/spec/features/early_career_payments/early_career_payments_claim_spec.rb +++ b/spec/features/early_career_payments/early_career_payments_claim_spec.rb @@ -95,7 +95,7 @@ expect(page).to have_text(I18n.t("additional_payments.check_your_answers.part_one.primary_heading")) expect(page).to have_text(I18n.t("additional_payments.check_your_answers.part_one.secondary_heading")) expect(page).to have_text(I18n.t("additional_payments.check_your_answers.part_one.confirmation_notice")) - expect(page).not_to have_text(I18n.t("additional_payments.questions.eligible_degree_subject")) + expect(page).not_to have_text(I18n.t("additional_payments.forms.eligible_degree_subject.questions.eligible_degree_subject")) %w[Identity\ details Payment\ details].each do |section_heading| expect(page).not_to have_text section_heading diff --git a/spec/forms/form_spec.rb b/spec/forms/form_spec.rb index de7e53d8b9..ebfa528cd0 100644 --- a/spec/forms/form_spec.rb +++ b/spec/forms/form_spec.rb @@ -215,7 +215,7 @@ def initialize(journey_session) context "with params containing attributes defined on the form" do it "permits the attributes in the params" do - expect(form.permitted_params).to eq(claim_params.stringify_keys) + expect(form.permitted_params).to eql(ActionController::Parameters.new(claim_params.stringify_keys).permit!) end end diff --git a/spec/helpers/admin/journey_configurations_helper_spec.rb b/spec/helpers/admin/journey_configurations_helper_spec.rb index e27bde6e87..1229244ccf 100644 --- a/spec/helpers/admin/journey_configurations_helper_spec.rb +++ b/spec/helpers/admin/journey_configurations_helper_spec.rb @@ -3,7 +3,7 @@ RSpec.describe Admin::JourneyConfigurationsHelper, type: :helper do describe "#options_for_academic_year" do it "returns the current and next academic year (based on September 1st being the start of the year)" do - travel_to Date.new(2018, 8, 31) do + travel_to Time.new(2018, 8, 31, 12) do expect(helper.options_for_academic_year).to eq [ AcademicYear.new(2017), AcademicYear.new(2018), @@ -11,7 +11,7 @@ AcademicYear.new(2020) ] end - travel_to Date.new(2018, 9, 1) do + travel_to Time.new(2018, 9, 1, 12) do expect(helper.options_for_academic_year).to eq [ AcademicYear.new(2018), AcademicYear.new(2019), @@ -19,7 +19,7 @@ AcademicYear.new(2021) ] end - travel_to Date.new(2020, 9, 1) do + travel_to Time.new(2020, 9, 1, 12) do expect(helper.options_for_academic_year).to eq [ AcademicYear.new(2020), AcademicYear.new(2021), diff --git a/spec/helpers/admin/payroll_run_helper_spec.rb b/spec/helpers/admin/payroll_run_helper_spec.rb index f45639f48d..56e28c7c8a 100644 --- a/spec/helpers/admin/payroll_run_helper_spec.rb +++ b/spec/helpers/admin/payroll_run_helper_spec.rb @@ -6,7 +6,7 @@ let(:third_friday_of_january_2020) { Date.new(2020, 1, 17) } it "returns the third to last Friday of the current month" do - travel_to Date.new(2020, 1, 1) do + travel_to Time.new(2020, 1, 1, 12) do expect(helper.next_payroll_file_due_date).to eql(third_friday_of_january_2020) end end @@ -14,10 +14,10 @@ context "when the payroll run has already happended this month" do let(:third_friday_of_november_2019) { Date.new(2019, 11, 15) } - let!(:payroll_run_this_month) { create(:payroll_run, created_at: Date.new(2019, 10, 1)) } + let!(:payroll_run_this_month) { create(:payroll_run, created_at: Time.new(2019, 10, 1, 12)) } it "returns the third to last Friday of the following month" do - travel_to Date.new(2019, 10, 10) do + travel_to Time.new(2019, 10, 10, 12) do expect(helper.next_payroll_file_due_date).to eql(third_friday_of_november_2019) end end diff --git a/spec/jobs/early_years_progress_emails_job_spec.rb b/spec/jobs/early_years_progress_emails_job_spec.rb index 5366cfdd69..53c3837a6c 100644 --- a/spec/jobs/early_years_progress_emails_job_spec.rb +++ b/spec/jobs/early_years_progress_emails_job_spec.rb @@ -12,7 +12,7 @@ context "when normal day of the month" do it "enqueues jobs normally" do - travel_to(Date.new(2024, 11, 12)) do + travel_to(Time.new(2024, 11, 12, 12)) do create(:claim, :submitted, policy:, submitted_at: 2.months.ago - 1.day) claim_2 = create(:claim, :submitted, policy:, submitted_at: 2.months.ago) create(:claim, :submitted, policy:, submitted_at: 2.months.ago + 1.day) @@ -31,7 +31,7 @@ context "when current month same number of days as previous month" do it "enqueues jobs normally" do - travel_to(Date.new(2024, 12, 31)) do + travel_to(Time.new(2024, 12, 31, 12)) do create(:claim, :submitted, policy:, submitted_at: 2.months.ago - 1.day) claim_2 = create(:claim, :submitted, policy:, submitted_at: 2.months.ago) create(:claim, :submitted, policy:, submitted_at: 2.months.ago + 1.day) @@ -49,21 +49,21 @@ claim_2 = create(:claim, :submitted, policy:, submitted_at: Date.new(2024, 2, 29)) claim_3 = create(:claim, :submitted, policy:, submitted_at: Date.new(2024, 3, 1)) - travel_to(Date.new(2024, 4, 28)) do + travel_to(Time.new(2024, 4, 28, 12)) do expect { subject.perform }.to have_enqueued_job.once expect(GlobalID::Locator.locate(queue_adapter.enqueued_jobs[0].dig(:args, 3, "params", "claim", "_aj_globalid"))).to eql(claim_1) end - travel_to(Date.new(2024, 4, 29)) do + travel_to(Time.new(2024, 4, 29, 12)) do expect { subject.perform }.to have_enqueued_job.once expect(GlobalID::Locator.locate(queue_adapter.enqueued_jobs[1].dig(:args, 3, "params", "claim", "_aj_globalid"))).to eql(claim_2) end - travel_to(Date.new(2024, 4, 30)) do + travel_to(Time.new(2024, 4, 30, 12)) do expect { subject.perform }.not_to have_enqueued_job end - travel_to(Date.new(2024, 5, 1)) do + travel_to(Time.new(2024, 5, 1, 12)) do expect { subject.perform }.to have_enqueued_job.once expect(GlobalID::Locator.locate(queue_adapter.enqueued_jobs[2].dig(:args, 3, "params", "claim", "_aj_globalid"))).to eql(claim_3) end @@ -77,12 +77,12 @@ claim_3 = create(:claim, :submitted, policy:, submitted_at: Date.new(2024, 7, 31)) claim_4 = create(:claim, :submitted, policy:, submitted_at: Date.new(2024, 8, 1)) - travel_to(Date.new(2024, 9, 29)) do + travel_to(Time.new(2024, 9, 29, 12)) do expect { subject.perform }.to have_enqueued_job.once expect(GlobalID::Locator.locate(queue_adapter.enqueued_jobs[0].dig(:args, 3, "params", "claim", "_aj_globalid"))).to eql(claim_1) end - travel_to(Date.new(2024, 9, 30)) do + travel_to(Time.new(2024, 9, 30, 12)) do expect { subject.perform }.to have_enqueued_job.twice expect do @@ -95,7 +95,7 @@ end end - travel_to(Date.new(2024, 10, 1)) do + travel_to(Time.new(2024, 10, 1, 12)) do expect { subject.perform }.to have_enqueued_job.once expect(GlobalID::Locator.locate(queue_adapter.enqueued_jobs[3].dig(:args, 3, "params", "claim", "_aj_globalid"))).to eql(claim_4) end diff --git a/spec/models/academic_year_spec.rb b/spec/models/academic_year_spec.rb index 7a2f0f2816..00e6e4d534 100644 --- a/spec/models/academic_year_spec.rb +++ b/spec/models/academic_year_spec.rb @@ -3,13 +3,13 @@ RSpec.describe AcademicYear do describe ".current" do it "returns the current academic year (based on September 1st being the start of the year)" do - travel_to Date.new(2018, 8, 31) do + travel_to Time.new(2018, 8, 31, 12) do expect(AcademicYear.current).to eq AcademicYear.new(2017) end - travel_to Date.new(2018, 9, 1) do + travel_to Time.new(2018, 9, 1, 12) do expect(AcademicYear.current).to eq AcademicYear.new(2018) end - travel_to Date.new(2020, 9, 1) do + travel_to Time.new(2020, 9, 1, 12) do expect(AcademicYear.current).to eq AcademicYear.new(2020) end end diff --git a/spec/models/policies/early_years_payments/admin_claim_details_presenter_spec.rb b/spec/models/policies/early_years_payments/admin_claim_details_presenter_spec.rb index 71b3159f7d..d41f8b522a 100644 --- a/spec/models/policies/early_years_payments/admin_claim_details_presenter_spec.rb +++ b/spec/models/policies/early_years_payments/admin_claim_details_presenter_spec.rb @@ -164,12 +164,12 @@ end context "when near the decision deadline" do - before { travel_to claim.decision_deadline_date - 1.week } - it "shows the days left until the deadline" do - expect(subject).to include( - [I18n.t("admin.decision_overdue"), "7 days"] - ) + travel_to(claim.decision_deadline_date - 1.week + 2.hours) do + expect(subject).to include( + [I18n.t("admin.decision_overdue"), "7 days"] + ) + end end end end diff --git a/spec/models/policies/early_years_payments/eligibility_spec.rb b/spec/models/policies/early_years_payments/eligibility_spec.rb index 6753f30ad3..e951cbd2c9 100644 --- a/spec/models/policies/early_years_payments/eligibility_spec.rb +++ b/spec/models/policies/early_years_payments/eligibility_spec.rb @@ -15,21 +15,27 @@ subject { eligibility.employment_task_available? } context "before 6 months from start date" do - before { travel_to eligibility.start_date } - - it { is_expected.to be false } + it do + travel_to(eligibility.start_date) do + is_expected.to be_falsey + end + end end context "exactly 6 months from start date" do - before { travel_to eligibility.start_date + 6.months } - - it { is_expected.to be true } + it do + travel_to(eligibility.start_date + 6.months - 2.hours) do + is_expected.to be_falsey + end + end end context "after 6 months from start date" do - before { travel_to eligibility.start_date + 6.months + 1.day } - - it { is_expected.to be true } + it do + travel_to(eligibility.start_date + 6.months + 2.hours) do + is_expected.to be_truthy + end + end end end end diff --git a/spec/models/policies/international_relocation_payments/claim_personal_data_scrubber_spec.rb b/spec/models/policies/international_relocation_payments/claim_personal_data_scrubber_spec.rb index a0fb4e11ef..2d09cbad16 100644 --- a/spec/models/policies/international_relocation_payments/claim_personal_data_scrubber_spec.rb +++ b/spec/models/policies/international_relocation_payments/claim_personal_data_scrubber_spec.rb @@ -7,7 +7,7 @@ ) it "retains name and national insurance number for 2 years" do - last_academic_year = Time.zone.local(AcademicYear.current.start_year, 8, 1) + last_academic_year = Time.zone.local(AcademicYear.current.start_year, 8, 1, 12) approved_claim = create( :claim, @@ -85,7 +85,7 @@ ) ) - travel_to(AcademicYear.current.start_of_autumn_term + 2.years) do + travel_to(AcademicYear.current.start_of_autumn_term + 2.years + 2.hours) do expect { described_class.new.scrub_completed_claims }.to( change { approved_claim.reload.first_name }.to(nil) .and( diff --git a/spec/support/admin_view_claim_feature_shared_examples.rb b/spec/support/admin_view_claim_feature_shared_examples.rb index 0ad3d6f4c2..4feebf5588 100644 --- a/spec/support/admin_view_claim_feature_shared_examples.rb +++ b/spec/support/admin_view_claim_feature_shared_examples.rb @@ -83,7 +83,7 @@ else AcademicYear.new(2019) end - @within_academic_year = Time.zone.local(current_academic_year.start_year, 9, 1) + @within_academic_year = Time.zone.local(current_academic_year.start_year, 9, 1, 12) end scenario "#{policy} filter approved awaiting payroll claims" do diff --git a/spec/support/admin_view_claim_logged_in_with_tid_feature_shared_examples.rb b/spec/support/admin_view_claim_logged_in_with_tid_feature_shared_examples.rb index fa241b4dd1..086a70e0d8 100644 --- a/spec/support/admin_view_claim_logged_in_with_tid_feature_shared_examples.rb +++ b/spec/support/admin_view_claim_logged_in_with_tid_feature_shared_examples.rb @@ -44,7 +44,7 @@ else AcademicYear.new(2019) end - @within_academic_year = Time.zone.local(current_academic_year.start_year, 9, 1) + @within_academic_year = Time.zone.local(current_academic_year.start_year, 9, 1, 12) end scenario "#{policy} view claim logged in with tid" do