Skip to content

Commit

Permalink
Upgrade to Rails 7.2 (#1125)
Browse files Browse the repository at this point in the history
* address deprecations for move to Rails 7.2

* workaround to continue using plaintext config/secrets.yml

* update to Rails 7.2

* update rspec-rails to support the Rails version

* update generated RSpec files

* merge in changes in Rails 7.2 files generated by rails app:update

* switch to new Rails 7.2 config defaults

* update schema.rb

* adapt the default pool size in database.yml to match new default puma thread count

* remove superfluous public files
  • Loading branch information
Ithanil authored Dec 3, 2024
1 parent 3090882 commit f8680b9
Show file tree
Hide file tree
Showing 15 changed files with 171 additions and 136 deletions.
4 changes: 2 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ git_source(:github) { |repo| "https://github.com/#{repo}.git" }
ruby '>= 3.0.0'

# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 7.1'
gem 'rails', '~> 7.2'
# Use Puma as the app server
gem 'puma', '~> 6.4'

Expand Down Expand Up @@ -43,7 +43,7 @@ group :development, :test do
gem 'dotenv-rails'
gem 'factory_bot_rails'

gem 'rspec-rails', '~> 5.1.2'
gem 'rspec-rails', '~> 7.1'

gem 'rubocop', '~> 1.50.0', require: false
gem 'rubocop-performance', require: false
Expand Down
176 changes: 88 additions & 88 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,84 +1,82 @@
GEM
remote: https://rubygems.org/
specs:
actioncable (7.1.4.1)
actionpack (= 7.1.4.1)
activesupport (= 7.1.4.1)
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.4.1)
actionpack (= 7.1.4.1)
activejob (= 7.1.4.1)
activerecord (= 7.1.4.1)
activestorage (= 7.1.4.1)
activesupport (= 7.1.4.1)
mail (>= 2.7.1)
net-imap
net-pop
net-smtp
actionmailer (7.1.4.1)
actionpack (= 7.1.4.1)
actionview (= 7.1.4.1)
activejob (= 7.1.4.1)
activesupport (= 7.1.4.1)
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.4.1)
actionview (= 7.1.4.1)
activesupport (= 7.1.4.1)
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.4.1)
actionpack (= 7.1.4.1)
activerecord (= 7.1.4.1)
activestorage (= 7.1.4.1)
activesupport (= 7.1.4.1)
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.4.1)
activesupport (= 7.1.4.1)
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.4.1)
activesupport (= 7.1.4.1)
activejob (7.2.2)
activesupport (= 7.2.2)
globalid (>= 0.3.6)
activemodel (7.1.4.1)
activesupport (= 7.1.4.1)
activerecord (7.1.4.1)
activemodel (= 7.1.4.1)
activesupport (= 7.1.4.1)
activemodel (7.2.2)
activesupport (= 7.2.2)
activerecord (7.2.2)
activemodel (= 7.2.2)
activesupport (= 7.2.2)
timeout (>= 0.4.0)
activestorage (7.1.4.1)
actionpack (= 7.1.4.1)
activejob (= 7.1.4.1)
activerecord (= 7.1.4.1)
activesupport (= 7.1.4.1)
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.4.1)
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
tzinfo (~> 2.0)
securerandom (>= 0.3)
tzinfo (~> 2.0, >= 2.0.5)
addressable (2.8.4)
public_suffix (>= 2.0.2, < 6.0)
ast (2.4.2)
base64 (0.2.0)
benchmark (0.4.0)
bigdecimal (3.1.8)
bootsnap (1.16.0)
msgpack (~> 1.2)
Expand All @@ -89,8 +87,8 @@ GEM
crack (0.4.5)
rexml
crass (1.0.6)
date (3.3.4)
diff-lcs (1.5.0)
date (3.4.1)
diff-lcs (1.5.1)
dotenv (2.8.1)
dotenv-rails (2.8.1)
dotenv (= 2.8.1)
Expand Down Expand Up @@ -121,6 +119,7 @@ GEM
listen (3.9.0)
rb-fsevent (~> 0.10, >= 0.10.3)
rb-inotify (~> 0.9, >= 0.9.10)
logger (1.6.2)
loofah (2.22.0)
crass (~> 1.0.2)
nokogiri (>= 1.12.0)
Expand All @@ -135,8 +134,7 @@ GEM
minitest (5.25.1)
minitest-stub_any_instance (1.0.3)
msgpack (1.7.0)
mutex_m (0.2.0)
net-imap (0.4.17)
net-imap (0.5.1)
date
net-protocol
net-pop (0.1.2)
Expand Down Expand Up @@ -167,20 +165,20 @@ GEM
rackup (2.1.0)
rack (>= 3)
webrick (~> 1.8)
rails (7.1.4.1)
actioncable (= 7.1.4.1)
actionmailbox (= 7.1.4.1)
actionmailer (= 7.1.4.1)
actionpack (= 7.1.4.1)
actiontext (= 7.1.4.1)
actionview (= 7.1.4.1)
activejob (= 7.1.4.1)
activemodel (= 7.1.4.1)
activerecord (= 7.1.4.1)
activestorage (= 7.1.4.1)
activesupport (= 7.1.4.1)
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.4.1)
railties (= 7.2.2)
rails-controller-testing (1.0.5)
actionpack (>= 5.0.1.rc1)
actionview (>= 5.0.1.rc1)
Expand All @@ -192,10 +190,10 @@ GEM
rails-html-sanitizer (1.6.0)
loofah (~> 2.21)
nokogiri (~> 1.14)
railties (7.1.4.1)
actionpack (= 7.1.4.1)
activesupport (= 7.1.4.1)
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)
Expand All @@ -214,23 +212,23 @@ GEM
reline (0.5.10)
io-console (~> 0.5)
rexml (3.3.9)
rspec-core (3.12.1)
rspec-support (~> 3.12.0)
rspec-expectations (3.12.2)
rspec-core (3.13.2)
rspec-support (~> 3.13.0)
rspec-expectations (3.13.3)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.12.0)
rspec-mocks (3.12.5)
rspec-support (~> 3.13.0)
rspec-mocks (3.13.2)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.12.0)
rspec-rails (5.1.2)
actionpack (>= 5.2)
activesupport (>= 5.2)
railties (>= 5.2)
rspec-core (~> 3.10)
rspec-expectations (~> 3.10)
rspec-mocks (~> 3.10)
rspec-support (~> 3.10)
rspec-support (3.12.0)
rspec-support (~> 3.13.0)
rspec-rails (7.1.0)
actionpack (>= 7.0)
activesupport (>= 7.0)
railties (>= 7.0)
rspec-core (~> 3.13)
rspec-expectations (~> 3.13)
rspec-mocks (~> 3.13)
rspec-support (~> 3.13)
rspec-support (3.13.1)
rubocop (1.50.1)
json (~> 2.3)
parallel (~> 1.10)
Expand All @@ -256,6 +254,7 @@ GEM
rubocop (~> 1.33)
rubocop-capybara (~> 2.17)
ruby-progressbar (1.13.0)
securerandom (0.4.0)
spring (4.2.1)
spring-watcher-listen (2.1.0)
listen (>= 2.7, < 4.0)
Expand All @@ -267,11 +266,12 @@ GEM
tty-screen (= 0.8.1)
unicode-display_width (~> 2.2)
thor (1.3.2)
timeout (0.4.1)
timeout (0.4.2)
tty-screen (0.8.1)
tzinfo (2.0.6)
concurrent-ruby (~> 1.0)
unicode-display_width (2.4.2)
useragent (0.16.10)
webmock (3.18.1)
addressable (>= 2.8.0)
crack (>= 0.3.2)
Expand All @@ -298,11 +298,11 @@ DEPENDENCIES
minitest-stub_any_instance
pg (~> 1.4.4)
puma (~> 6.4)
rails (~> 7.1)
rails (~> 7.2)
rails-controller-testing
redis (~> 4.8.0)
redis-namespace (~> 1.11.0)
rspec-rails (~> 5.1.2)
rspec-rails (~> 7.1)
rubocop (~> 1.50.0)
rubocop-performance
rubocop-rails (~> 2.19.0)
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/health_check_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,6 @@ def cache_check

def database_check
raise 'Database not responding' if defined?(ActiveRecord) && !ActiveRecord::Migrator.current_version
raise 'Pending migrations' unless ActiveRecord::Migration.check_pending!.nil?
raise 'Pending migrations' unless ActiveRecord::Migration.check_all_pending!.nil?
end
end
4 changes: 2 additions & 2 deletions app/controllers/playback_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def create_cookie
'sub' => resource_path,
'exp' => expires,
}
secret = Rails.application.secrets.secret_key_base
secret = Rails.configuration.secrets.secret_key_base
token = JWT.encode(payload, secret, 'HS256')

cookies[cookie_name] = {
Expand All @@ -74,7 +74,7 @@ def verify_cookie
raise RecordingNotFoundError if cookie.blank?

resource_path = "/#{@playback_format.format}/#{@recording.record_id}"
secret = Rails.application.secrets.secret_key_base
secret = Rails.configuration.secrets.secret_key_base
JWT.decode(
cookie,
secret,
Expand Down
4 changes: 4 additions & 0 deletions bin/setup
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,8 @@ FileUtils.chdir APP_ROOT do

puts "\n== Restarting application server =="
system! 'bin/rails restart'

# puts "\n== Configuring puma-dev =="
# system "ln -nfs #{APP_ROOT} ~/.puma-dev/#{APP_NAME}"
# system "curl -Is https://#{APP_NAME}.test/up | head -n 1"
end
7 changes: 5 additions & 2 deletions config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@
module Scalelite
class Application < Rails::Application
# Initialize configuration defaults
config.load_defaults 7.1
config.load_defaults 7.2

# Please, add to the `ignore` list any other `lib` subdirectories that do
# not contain `.rb` files, or that should not be reloaded or eager loaded.
# Common ones are `templates`, `generators`, or `middleware`, for example.
config.autoload_lib(ignore: %w(tasks))
config.autoload_lib(ignore: %w[tasks])

# Configuration for the application, engines, and railties goes here.
#
Expand Down Expand Up @@ -168,5 +168,8 @@ class Application < Rails::Application

# Restore default serializer from Rails defaults < 7.1
config.active_record.default_column_serializer = YAML

# continue using config/secrets.yml for secrets
config.secrets = config_for(:secrets)
end
end
2 changes: 1 addition & 1 deletion config/database.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
default: &default
pool: <%= ENV.fetch('RAILS_MAX_THREADS') { 5 } %>
pool: <%= ENV.fetch('RAILS_MAX_THREADS') { 3 } %>
timeout: 5000
adapter: postgresql
encoding: unicode
Expand Down
7 changes: 2 additions & 5 deletions config/environments/development.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
# Show full error reports.
config.consider_all_requests_local = true

# Enable server timing
# Enable server timing.
config.server_timing = true

# Enable/disable caching. By default caching is disabled.
Expand Down Expand Up @@ -60,15 +60,12 @@
# Annotate rendered view with file names.
# config.action_view.annotate_rendered_view_with_filenames = true

# Raise error when a before_action's only/except options reference missing actions
# Raise error when a before_action's only/except options reference missing actions.
config.action_controller.raise_on_missing_callback_actions = true

# Use an evented file watcher to asynchronously detect changes in source code,
# routes, locales, etc. This feature depends on the listen gem.
config.file_watcher = ActiveSupport::EventedFileUpdateChecker

# Uncomment if you wish to allow Action Cable access from any origin.
# config.action_cable.disable_request_forgery_protection = true

config.hosts = nil
end
Loading

0 comments on commit f8680b9

Please sign in to comment.