diff --git a/Gemfile b/Gemfile index 7da3cada3..0d67e2d9b 100644 --- a/Gemfile +++ b/Gemfile @@ -5,7 +5,7 @@ git_source(:github) { |repo| "https://github.com/#{repo}.git" } ruby File.read('.ruby-version') -gem 'rails', '~> 6.1' +gem 'rails', '~> 7.0.8' gem 'activerecord-import' gem 'auto_strip_attributes' @@ -76,7 +76,7 @@ group :development do gem 'listen' gem 'rails-erd' gem 'rubocop-govuk' - gem 'spring' + gem 'spring', '>= 3' gem 'spring-watcher-listen' end diff --git a/Gemfile.lock b/Gemfile.lock index 2ab99739f..b6da1fa16 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,67 +1,73 @@ GEM remote: https://rubygems.org/ specs: - actioncable (6.1.7.4) - actionpack (= 6.1.7.4) - activesupport (= 6.1.7.4) + actioncable (7.0.8) + actionpack (= 7.0.8) + activesupport (= 7.0.8) nio4r (~> 2.0) websocket-driver (>= 0.6.1) - actionmailbox (6.1.7.4) - actionpack (= 6.1.7.4) - activejob (= 6.1.7.4) - activerecord (= 6.1.7.4) - activestorage (= 6.1.7.4) - activesupport (= 6.1.7.4) + actionmailbox (7.0.8) + actionpack (= 7.0.8) + activejob (= 7.0.8) + activerecord (= 7.0.8) + activestorage (= 7.0.8) + activesupport (= 7.0.8) mail (>= 2.7.1) - actionmailer (6.1.7.4) - actionpack (= 6.1.7.4) - actionview (= 6.1.7.4) - activejob (= 6.1.7.4) - activesupport (= 6.1.7.4) + net-imap + net-pop + net-smtp + actionmailer (7.0.8) + actionpack (= 7.0.8) + actionview (= 7.0.8) + activejob (= 7.0.8) + activesupport (= 7.0.8) mail (~> 2.5, >= 2.5.4) + net-imap + net-pop + net-smtp rails-dom-testing (~> 2.0) - actionpack (6.1.7.4) - actionview (= 6.1.7.4) - activesupport (= 6.1.7.4) - rack (~> 2.0, >= 2.0.9) + actionpack (7.0.8) + actionview (= 7.0.8) + activesupport (= 7.0.8) + rack (~> 2.0, >= 2.2.4) rack-test (>= 0.6.3) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.0, >= 1.2.0) - actiontext (6.1.7.4) - actionpack (= 6.1.7.4) - activerecord (= 6.1.7.4) - activestorage (= 6.1.7.4) - activesupport (= 6.1.7.4) + actiontext (7.0.8) + actionpack (= 7.0.8) + activerecord (= 7.0.8) + activestorage (= 7.0.8) + activesupport (= 7.0.8) + globalid (>= 0.6.0) nokogiri (>= 1.8.5) - actionview (6.1.7.4) - activesupport (= 6.1.7.4) + actionview (7.0.8) + activesupport (= 7.0.8) builder (~> 3.1) erubi (~> 1.4) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.1, >= 1.2.0) - activejob (6.1.7.4) - activesupport (= 6.1.7.4) + activejob (7.0.8) + activesupport (= 7.0.8) globalid (>= 0.3.6) - activemodel (6.1.7.4) - activesupport (= 6.1.7.4) - activerecord (6.1.7.4) - activemodel (= 6.1.7.4) - activesupport (= 6.1.7.4) + activemodel (7.0.8) + activesupport (= 7.0.8) + activerecord (7.0.8) + activemodel (= 7.0.8) + activesupport (= 7.0.8) activerecord-import (1.4.1) activerecord (>= 4.2) - activestorage (6.1.7.4) - actionpack (= 6.1.7.4) - activejob (= 6.1.7.4) - activerecord (= 6.1.7.4) - activesupport (= 6.1.7.4) + activestorage (7.0.8) + actionpack (= 7.0.8) + activejob (= 7.0.8) + activerecord (= 7.0.8) + activesupport (= 7.0.8) marcel (~> 1.0) mini_mime (>= 1.1.0) - activesupport (6.1.7.4) + activesupport (7.0.8) concurrent-ruby (~> 1.0, >= 1.0.2) i18n (>= 1.6, < 2) minitest (>= 5.1) tzinfo (~> 2.0) - zeitwerk (~> 2.3) addressable (2.8.5) public_suffix (>= 2.0.2, < 6.0) ast (2.4.2) @@ -174,8 +180,8 @@ GEM octokit (~> 4.6) rainbow (>= 2.2.1) rake (>= 10.0) - globalid (1.1.0) - activesupport (>= 5.0) + globalid (1.2.1) + activesupport (>= 6.1) govuk_notify_rails (2.2.0) notifications-ruby-client (~> 5.1) rails (>= 4.1.0) @@ -224,7 +230,7 @@ GEM method_source (1.0.0) mini_mime (1.1.5) mini_portile2 (2.8.4) - minitest (5.19.0) + minitest (5.20.0) msgpack (1.7.2) multi_json (1.15.0) multi_xml (0.6.0) @@ -287,21 +293,20 @@ GEM rack (>= 2.0.0) rack-test (2.1.0) rack (>= 1.3) - rails (6.1.7.4) - actioncable (= 6.1.7.4) - actionmailbox (= 6.1.7.4) - actionmailer (= 6.1.7.4) - actionpack (= 6.1.7.4) - actiontext (= 6.1.7.4) - actionview (= 6.1.7.4) - activejob (= 6.1.7.4) - activemodel (= 6.1.7.4) - activerecord (= 6.1.7.4) - activestorage (= 6.1.7.4) - activesupport (= 6.1.7.4) + rails (7.0.8) + actioncable (= 7.0.8) + actionmailbox (= 7.0.8) + actionmailer (= 7.0.8) + actionpack (= 7.0.8) + actiontext (= 7.0.8) + actionview (= 7.0.8) + activejob (= 7.0.8) + activemodel (= 7.0.8) + activerecord (= 7.0.8) + activestorage (= 7.0.8) + activesupport (= 7.0.8) bundler (>= 1.15.0) - railties (= 6.1.7.4) - sprockets-rails (>= 2.0.0) + railties (= 7.0.8) rails-dom-testing (2.2.0) activesupport (>= 5.0.0) minitest @@ -314,12 +319,13 @@ GEM rails-html-sanitizer (1.6.0) loofah (~> 2.21) nokogiri (~> 1.14) - railties (6.1.7.4) - actionpack (= 6.1.7.4) - activesupport (= 6.1.7.4) + railties (7.0.8) + actionpack (= 7.0.8) + activesupport (= 7.0.8) method_source rake (>= 12.2) thor (~> 1.0) + zeitwerk (~> 2.5) rainbow (3.1.1) rake (13.0.6) rb-fsevent (0.11.2) @@ -428,17 +434,10 @@ GEM snaky_hash (2.0.1) hashie version_gem (~> 1.1, >= 1.1.1) - spring (2.1.1) - spring-watcher-listen (2.0.1) + spring (4.1.1) + spring-watcher-listen (2.1.0) listen (>= 2.7, < 4.0) - spring (>= 1.2, < 3.0) - sprockets (4.2.0) - concurrent-ruby (~> 1.0) - rack (>= 2.2.4, < 4) - sprockets-rails (3.4.2) - actionpack (>= 5.2) - activesupport (>= 5.2) - sprockets (>= 3.0.0) + spring (>= 4) sync (0.5.0) terminal-table (3.0.2) unicode-display_width (>= 1.1.1, < 3) @@ -505,7 +504,7 @@ DEPENDENCIES puma rack-cors rack-test - rails (~> 6.1) + rails (~> 7.0.8) rails-erd redis routing-filter @@ -523,7 +522,7 @@ DEPENDENCIES sidekiq simplecov slack-notifier - spring + spring (>= 3) spring-watcher-listen terminal-table timecop diff --git a/app/controllers/api_controller.rb b/app/controllers/api_controller.rb index 6257ba6d8..6e82a8df6 100644 --- a/app/controllers/api_controller.rb +++ b/app/controllers/api_controller.rb @@ -92,7 +92,7 @@ def restricted_request_content_type end def restrict_request_content_type - return if request.content_type == restricted_request_content_type || valid_empty_request? + return if request.media_type == restricted_request_content_type || valid_empty_request? render_invalid_media_type_error('Invalid Media Type', "Content-Type must be #{restricted_request_content_type}") end @@ -222,7 +222,7 @@ def validation_errors(record) # Allow always-bodyless requests (GET, DELETE HEAD) to omit the Content-Type def valid_empty_request? - request.content_type.nil? && (request.get? || request.delete? || request.head?) + request.media_type.nil? && (request.get? || request.delete? || request.head?) end def render_validation_error(exception) diff --git a/app/models/person.rb b/app/models/person.rb index 231964ff4..c11c7c3b9 100644 --- a/app/models/person.rb +++ b/app/models/person.rb @@ -53,7 +53,7 @@ def attach_image(image_blob) "#{id}.jpg".tap do |filename| image_io = StringIO.new(image_blob).binmode begin - image.attach(io: image_io, filename: filename, content_type: 'image/jpg') + image.attach(io: image_io, filename: filename, content_type: 'image/jpeg') ensure image_io.close end diff --git a/app/services/allocations/create_in_nomis.rb b/app/services/allocations/create_in_nomis.rb index b43e8c0e4..842186fdf 100644 --- a/app/services/allocations/create_in_nomis.rb +++ b/app/services/allocations/create_in_nomis.rb @@ -10,7 +10,7 @@ def self.call(move) fromPrisonLocation: move.from_location.nomis_agency_id, toPrisonLocation: move.to_location.nomis_agency_id, escortType: 'PECS', - scheduledMoveDateTime: move.date.to_s(:nomis), + scheduledMoveDateTime: move.date.to_fs(:nomis), }, } diff --git a/app/services/court_hearings/create_in_nomis.rb b/app/services/court_hearings/create_in_nomis.rb index 6d70400ed..e66993c8d 100644 --- a/app/services/court_hearings/create_in_nomis.rb +++ b/app/services/court_hearings/create_in_nomis.rb @@ -15,7 +15,7 @@ def self.call(move, court_hearings) booking_id: booking_id, court_case_id: hearing.nomis_case_id, body_params: { - courtHearingDateTime: hearing.start_time.to_s(:nomis), + courtHearingDateTime: hearing.start_time.to_fs(:nomis), comments: hearing.comments, }.merge(body_locations), } diff --git a/app/services/encryptor.rb b/app/services/encryptor.rb index ef8197d0a..01729d007 100644 --- a/app/services/encryptor.rb +++ b/app/services/encryptor.rb @@ -6,6 +6,7 @@ class Encryptor KEY = ActiveSupport::KeyGenerator.new( Rails.application.secret_key_base, + { hash_digest_class: OpenSSL::Digest::SHA1 }, ).generate_key( ENV.fetch('ENCRYPTOR_SALT'), ActiveSupport::MessageEncryptor.key_len, diff --git a/config/application.rb b/config/application.rb index 9d1229bbc..03d8586b9 100644 --- a/config/application.rb +++ b/config/application.rb @@ -46,5 +46,8 @@ class Application < Rails::Application # Needed for PaperTrail to be able to deserialise saved versions config.active_record.yaml_column_permitted_classes = [Symbol, Date, Time] + + config.active_support.cache_format_version = 7.0 + config.active_support.disable_to_s_conversion = true end end diff --git a/config/environments/test.rb b/config/environments/test.rb index 199777dff..29a0c54d5 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -8,7 +8,7 @@ Rails.application.configure do # Settings specified here will take precedence over those in config/application.rb. - config.cache_classes = true + config.cache_classes = false # Do not eager load code on boot. This avoids loading your whole application # just for the purpose of running a single test. If you are using a tool that diff --git a/config/initializers/new_framework_defaults_7_0.rb b/config/initializers/new_framework_defaults_7_0.rb new file mode 100644 index 000000000..a1a678b5c --- /dev/null +++ b/config/initializers/new_framework_defaults_7_0.rb @@ -0,0 +1,143 @@ +# Be sure to restart your server when you modify this file. +# +# This file eases your Rails 7.0 framework defaults upgrade. +# +# Uncomment each configuration one by one to switch to the new default. +# Once your application is ready to run with all new defaults, you can remove +# this file and set the `config.load_defaults` to `7.0`. +# +# Read the Guide for Upgrading Ruby on Rails for more info on each option. +# https://guides.rubyonrails.org/upgrading_ruby_on_rails.html + +# `button_to` view helper will render `