Skip to content

Commit

Permalink
Merge pull request #2173 from ministryofjustice/rails-7-upgrade--MAP-253
Browse files Browse the repository at this point in the history


[MAP-253] Rails 7 upgrade
  • Loading branch information
jimbali authored Sep 28, 2023
2 parents 0751037 + ba75ca1 commit 3d9566f
Show file tree
Hide file tree
Showing 24 changed files with 375 additions and 198 deletions.
4 changes: 2 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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

Expand Down
141 changes: 70 additions & 71 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand All @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -505,7 +504,7 @@ DEPENDENCIES
puma
rack-cors
rack-test
rails (~> 6.1)
rails (~> 7.0.8)
rails-erd
redis
routing-filter
Expand All @@ -523,7 +522,7 @@ DEPENDENCIES
sidekiq
simplecov
slack-notifier
spring
spring (>= 3)
spring-watcher-listen
terminal-table
timecop
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/api_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion app/models/person.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion app/services/allocations/create_in_nomis.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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),
},
}

Expand Down
2 changes: 1 addition & 1 deletion app/services/court_hearings/create_in_nomis.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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),
}
Expand Down
1 change: 1 addition & 0 deletions app/services/encryptor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
3 changes: 3 additions & 0 deletions config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion config/environments/test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading

0 comments on commit 3d9566f

Please sign in to comment.