From c8c097af7a3c885b320503c6c2b0ea5e7234b0f0 Mon Sep 17 00:00:00 2001 From: Phil Lee Date: Thu, 28 Nov 2024 12:44:25 +0000 Subject: [PATCH 1/3] upgrade to rails 8 --- Gemfile | 2 +- Gemfile.lock | 123 ++++++++++++++++++++++++++------------------------- 2 files changed, 63 insertions(+), 62 deletions(-) diff --git a/Gemfile b/Gemfile index c0143dedd6..c0ba2baf14 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.2.2" +gem "rails", "~> 8.0" # 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 8a008c0606..8ecdc5529b 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -19,70 +19,69 @@ GIT GEM remote: https://rubygems.org/ specs: - actioncable (7.2.2) - actionpack (= 7.2.2) - activesupport (= 7.2.2) + actioncable (8.0.0) + actionpack (= 8.0.0) + activesupport (= 8.0.0) nio4r (~> 2.0) websocket-driver (>= 0.6.1) zeitwerk (~> 2.6) - actionmailbox (7.2.2) - actionpack (= 7.2.2) - activejob (= 7.2.2) - activerecord (= 7.2.2) - activestorage (= 7.2.2) - activesupport (= 7.2.2) + actionmailbox (8.0.0) + actionpack (= 8.0.0) + activejob (= 8.0.0) + activerecord (= 8.0.0) + activestorage (= 8.0.0) + activesupport (= 8.0.0) mail (>= 2.8.0) - actionmailer (7.2.2) - actionpack (= 7.2.2) - actionview (= 7.2.2) - activejob (= 7.2.2) - activesupport (= 7.2.2) + actionmailer (8.0.0) + actionpack (= 8.0.0) + actionview (= 8.0.0) + activejob (= 8.0.0) + activesupport (= 8.0.0) mail (>= 2.8.0) rails-dom-testing (~> 2.2) - actionpack (7.2.2) - actionview (= 7.2.2) - activesupport (= 7.2.2) + actionpack (8.0.0) + actionview (= 8.0.0) + activesupport (= 8.0.0) nokogiri (>= 1.8.5) - racc - rack (>= 2.2.4, < 3.2) + rack (>= 2.2.4) rack-session (>= 1.0.1) rack-test (>= 0.6.3) rails-dom-testing (~> 2.2) rails-html-sanitizer (~> 1.6) useragent (~> 0.16) - actiontext (7.2.2) - actionpack (= 7.2.2) - activerecord (= 7.2.2) - activestorage (= 7.2.2) - activesupport (= 7.2.2) + actiontext (8.0.0) + actionpack (= 8.0.0) + activerecord (= 8.0.0) + activestorage (= 8.0.0) + activesupport (= 8.0.0) globalid (>= 0.6.0) nokogiri (>= 1.8.5) - actionview (7.2.2) - activesupport (= 7.2.2) + actionview (8.0.0) + activesupport (= 8.0.0) builder (~> 3.1) erubi (~> 1.11) rails-dom-testing (~> 2.2) rails-html-sanitizer (~> 1.6) - activejob (7.2.2) - activesupport (= 7.2.2) + activejob (8.0.0) + activesupport (= 8.0.0) globalid (>= 0.3.6) - activemodel (7.2.2) - activesupport (= 7.2.2) - activerecord (7.2.2) - activemodel (= 7.2.2) - activesupport (= 7.2.2) + activemodel (8.0.0) + activesupport (= 8.0.0) + activerecord (8.0.0) + activemodel (= 8.0.0) + activesupport (= 8.0.0) timeout (>= 0.4.0) activerecord-copy (1.1.0) activerecord (>= 3.1) activerecord-nulldb-adapter (1.1.1) activerecord (>= 6.0, < 8.1) - activestorage (7.2.2) - actionpack (= 7.2.2) - activejob (= 7.2.2) - activerecord (= 7.2.2) - activesupport (= 7.2.2) + activestorage (8.0.0) + actionpack (= 8.0.0) + activejob (= 8.0.0) + activerecord (= 8.0.0) + activesupport (= 8.0.0) marcel (~> 1.0) - activesupport (7.2.2) + activesupport (8.0.0) base64 benchmark (>= 0.3) bigdecimal @@ -94,6 +93,7 @@ GEM minitest (>= 5.1) securerandom (>= 0.3) tzinfo (~> 2.0, >= 2.0.5) + uri (>= 0.13.1) addressable (2.8.7) public_suffix (>= 2.0.2, < 7.0) aes_key_wrap (1.1.0) @@ -109,7 +109,7 @@ GEM brakeman (6.2.1) racc builder (3.3.0) - bullet (7.2.0) + bullet (8.0.0) activesupport (>= 3.0.0) uniform_notifier (~> 1.11) capybara (3.40.0) @@ -136,10 +136,10 @@ GEM declarative (0.0.20) delayed_cron_job (0.9.0) fugit (>= 1.5) - delayed_job (4.1.12) - activesupport (>= 3.0, < 8.0) - delayed_job_active_record (4.1.10) - activerecord (>= 3.0, < 8.0) + delayed_job (4.1.13) + activesupport (>= 3.0, < 9.0) + delayed_job_active_record (4.1.11) + activerecord (>= 3.0, < 9.0) delayed_job (>= 3.0, < 5) diff-lcs (1.5.1) docile (1.4.0) @@ -629,20 +629,20 @@ GEM rack (>= 1.0.0) rackup (2.2.1) rack (>= 3) - rails (7.2.2) - actioncable (= 7.2.2) - actionmailbox (= 7.2.2) - actionmailer (= 7.2.2) - actionpack (= 7.2.2) - actiontext (= 7.2.2) - actionview (= 7.2.2) - activejob (= 7.2.2) - activemodel (= 7.2.2) - activerecord (= 7.2.2) - activestorage (= 7.2.2) - activesupport (= 7.2.2) + rails (8.0.0) + actioncable (= 8.0.0) + actionmailbox (= 8.0.0) + actionmailer (= 8.0.0) + actionpack (= 8.0.0) + actiontext (= 8.0.0) + actionview (= 8.0.0) + activejob (= 8.0.0) + activemodel (= 8.0.0) + activerecord (= 8.0.0) + activestorage (= 8.0.0) + activesupport (= 8.0.0) bundler (>= 1.15.0) - railties (= 7.2.2) + railties (= 8.0.0) rails-dom-testing (2.2.0) activesupport (>= 5.0.0) minitest @@ -654,9 +654,9 @@ GEM rack railties (>= 5.1) semantic_logger (~> 4.13) - railties (7.2.2) - actionpack (= 7.2.2) - activesupport (= 7.2.2) + railties (8.0.0) + actionpack (= 8.0.0) + activesupport (= 8.0.0) irb (~> 1.13) rackup (>= 1.0.0) rake (>= 12.2) @@ -811,6 +811,7 @@ GEM uk_postcode (2.1.8) unicode-display_width (2.6.0) uniform_notifier (1.16.0) + uri (1.0.2) useragent (0.16.10) validate_email (0.1.6) activemodel (>= 3.0) @@ -887,7 +888,7 @@ DEPENDENCIES puma (~> 6.4) rack-mini-profiler rack_session_access - rails (~> 7.2.2) + rails (~> 8.0) rails_semantic_logger rollbar rotp From 010e4942e8763c46fd7b97b48476687fc6dfab7c Mon Sep 17 00:00:00 2001 From: Phil Lee Date: Thu, 28 Nov 2024 12:44:39 +0000 Subject: [PATCH 2/3] rails 8 upgrade: fix SLC importer data casting --- app/models/student_loans_data_importer.rb | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/app/models/student_loans_data_importer.rb b/app/models/student_loans_data_importer.rb index 977b4fb6af..dc08e80777 100644 --- a/app/models/student_loans_data_importer.rb +++ b/app/models/student_loans_data_importer.rb @@ -28,12 +28,28 @@ def row_to_hash(row) full_name: row.fetch("Full name"), date_of_birth: cast_as_date(row.fetch("Date of birth")), policy_name: row.fetch("Policy name"), - no_of_plans_currently_repaying: row.fetch("No of Plans Currently Repaying"), - plan_type_of_deduction: row.fetch("Plan Type of Deduction"), + no_of_plans_currently_repaying: calculate_no_of_plans_currently_repaying(row.fetch("No of Plans Currently Repaying")), + plan_type_of_deduction: calculate_plan_type_of_deduction(row.fetch("Plan Type of Deduction")), amount: row.fetch("Amount") } end + def calculate_plan_type_of_deduction(value) + if value == "No data" + nil + else + value + end + end + + def calculate_no_of_plans_currently_repaying(value) + if value == "No data" + nil + else + value + end + end + def cast_as_date(string) Date.strptime(string, I18n.t("date.formats.day_month_year")) rescue TypeError, Date::Error From cb3631c2cfa412c257cc72157bcb8613e94ed8bc Mon Sep 17 00:00:00 2001 From: Phil Lee Date: Thu, 28 Nov 2024 13:05:11 +0000 Subject: [PATCH 3/3] support rails 8 deprecation - continues to use current existing behaviour of :offset --- config/application.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/config/application.rb b/config/application.rb index 379e695c5a..11a8fe4e0d 100644 --- a/config/application.rb +++ b/config/application.rb @@ -73,5 +73,7 @@ class Application < Rails::Application config.active_record.yaml_column_permitted_classes = [BigDecimal, Date, Symbol] config.email_regexp = /\A[a-zA-Z0-9.!\#$%&'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+\z/ + + config.active_support.to_time_preserves_timezone = :offset end end