Maintenance: Update to Rails 7.2

This commit is contained in:
Martin Gruner 2024-11-27 19:17:15 +01:00 committed by Mantas Masalskis
parent b54155478d
commit 180bc4acdb
5 changed files with 78 additions and 71 deletions

View file

@ -4,7 +4,7 @@ source 'https://rubygems.org'
# core - base
ruby '3.2.4'
gem 'rails', '~> 7.1.4'
gem 'rails', '~> 7.2.0'
# core - rails additions
gem 'activerecord-import'

View file

@ -33,63 +33,58 @@ GEM
simple_po_parser (~> 1.1.6)
aasm (5.5.0)
concurrent-ruby (~> 1.0)
actioncable (7.1.5)
actionpack (= 7.1.5)
activesupport (= 7.1.5)
actioncable (7.2.2)
actionpack (= 7.2.2)
activesupport (= 7.2.2)
nio4r (~> 2.0)
websocket-driver (>= 0.6.1)
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.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
actionmailbox (7.2.2)
actionpack (= 7.2.2)
activejob (= 7.2.2)
activerecord (= 7.2.2)
activestorage (= 7.2.2)
activesupport (= 7.2.2)
mail (>= 2.8.0)
actionmailer (7.2.2)
actionpack (= 7.2.2)
actionview (= 7.2.2)
activejob (= 7.2.2)
activesupport (= 7.2.2)
mail (>= 2.8.0)
rails-dom-testing (~> 2.2)
actionpack (7.1.5)
actionview (= 7.1.5)
activesupport (= 7.1.5)
actionpack (7.2.2)
actionview (= 7.2.2)
activesupport (= 7.2.2)
nokogiri (>= 1.8.5)
racc
rack (>= 2.2.4)
rack (>= 2.2.4, < 3.2)
rack-session (>= 1.0.1)
rack-test (>= 0.6.3)
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)
useragent (~> 0.16)
actiontext (7.2.2)
actionpack (= 7.2.2)
activerecord (= 7.2.2)
activestorage (= 7.2.2)
activesupport (= 7.2.2)
globalid (>= 0.6.0)
nokogiri (>= 1.8.5)
actionview (7.1.5)
activesupport (= 7.1.5)
actionview (7.2.2)
activesupport (= 7.2.2)
builder (~> 3.1)
erubi (~> 1.11)
rails-dom-testing (~> 2.2)
rails-html-sanitizer (~> 1.6)
activejob (7.1.5)
activesupport (= 7.1.5)
activejob (7.2.2)
activesupport (= 7.2.2)
globalid (>= 0.3.6)
activemodel (7.1.5)
activesupport (= 7.1.5)
activerecord (7.1.5)
activemodel (= 7.1.5)
activesupport (= 7.1.5)
activemodel (7.2.2)
activesupport (= 7.2.2)
activerecord (7.2.2)
activemodel (= 7.2.2)
activesupport (= 7.2.2)
timeout (>= 0.4.0)
activerecord-import (1.8.1)
activerecord (>= 4.2)
@ -100,25 +95,24 @@ GEM
multi_json (~> 1.11, >= 1.11.2)
rack (>= 2.0.8, < 4)
railties (>= 6.1)
activestorage (7.1.5)
actionpack (= 7.1.5)
activejob (= 7.1.5)
activerecord (= 7.1.5)
activesupport (= 7.1.5)
activestorage (7.2.2)
actionpack (= 7.2.2)
activejob (= 7.2.2)
activerecord (= 7.2.2)
activesupport (= 7.2.2)
marcel (~> 1.0)
activesupport (7.1.5)
activesupport (7.2.2)
base64
benchmark (>= 0.3)
bigdecimal
concurrent-ruby (~> 1.0, >= 1.0.2)
concurrent-ruby (~> 1.0, >= 1.3.1)
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)
tzinfo (~> 2.0, >= 2.0.5)
acts_as_list (1.2.4)
activerecord (>= 6.1)
activesupport (>= 6.1)
@ -202,7 +196,7 @@ GEM
csv (3.3.0)
daemons (1.4.1)
dalli (3.2.8)
date (3.3.4)
date (3.4.0)
debug_inspector (1.2.0)
delayed_job (4.1.13)
activesupport (>= 3.0, < 9.0)
@ -371,7 +365,6 @@ GEM
multi_xml (0.7.1)
bigdecimal (~> 3.1)
multipart-post (2.4.1)
mutex_m (0.2.0)
mysql2 (0.5.6)
naught (1.1.0)
nestful (1.1.4)
@ -514,20 +507,20 @@ GEM
rackup (1.0.0)
rack (< 3)
webrick
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)
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)
bundler (>= 1.15.0)
railties (= 7.1.5)
railties (= 7.2.2)
rails-controller-testing (1.0.5)
actionpack (>= 5.0.1.rc1)
actionview (>= 5.0.1.rc1)
@ -539,10 +532,10 @@ GEM
rails-html-sanitizer (1.6.0)
loofah (~> 2.21)
nokogiri (~> 1.14)
railties (7.1.5)
actionpack (= 7.1.5)
activesupport (= 7.1.5)
irb
railties (7.2.2)
actionpack (= 7.2.2)
activesupport (= 7.2.2)
irb (~> 1.13)
rackup (>= 1.0.0)
rake (>= 12.2)
thor (~> 1.0, >= 1.2.2)
@ -714,6 +707,7 @@ GEM
tzinfo (>= 1.0.0)
unicode-display_width (2.6.0)
uri (0.13.1)
useragent (0.16.10)
vcr (6.3.1)
base64
version_gem (1.1.4)
@ -851,7 +845,7 @@ DEPENDENCIES
pundit
pundit-matchers
rack-attack
rails (~> 7.1.4)
rails (~> 7.2.0)
rails-controller-testing
rchardet (>= 1.8.0)
redis (>= 3, < 5)

View file

@ -7,6 +7,12 @@ class ApplicationJob < ActiveJob::Base
discard_on HasActiveJobLock::LockKeyNotGeneratable
# Rails 7.2 changed how background jobs are handled inside ActiveRecord transaction.
# Turns out some jobs are still enqueued within transaction which is a bad practice.
# For now, this reverts to pre-7.2 behavior.
# Jobs enqueued inside transaction should be moved to post-transaction callbacks in the future.
self.enqueue_after_transaction_commit = :never
ActiveJob::LogSubscriber.detach_from :active_job
# See config/initializers/delayed_jobs_timeout_per_job.rb for details.

View file

@ -20,7 +20,7 @@ end
module Zammad
class Application < Rails::Application
# Initialize configuration defaults for originally generated Rails version.
config.load_defaults 7.1
config.load_defaults 7.2
Rails.autoloaders.each do |autoloader|
autoloader.ignore "#{config.root}/app/frontend"

View file

@ -65,6 +65,13 @@ class BackgroundServices
Rails.logger.debug { "Starting thread for service #{service.service_name} in the main process." }
service.new.run
# BackgroundServices rspec test is using Timeout.timeout to stop background services.
# It was fine for a long time, but started throwing following error in Rails 7.2.
# This seems to affect that test case only.
# Unfortunately, since it's running on a separate thread, that error has to be rescued here.
# That said, this should be handled by improving services loops to support graceful exiting.
rescue ActiveRecord::ActiveRecordError => e
raise e if Rails.env.test? && e.message != 'Cannot expire connection, it is not currently leased.' # rubocop:disable Zammad/DetectTranslatableString
end
end
end