From d99b89df0ace28a15eec97faa239db5954fdf790 Mon Sep 17 00:00:00 2001 From: Ynda Jas Date: Wed, 26 Jun 2024 13:53:15 +0100 Subject: [PATCH 1/6] Turn off class caching in test environment This fixes a runtime error. We've had to do similar in the DfSSETA example app and RODA after various upgrades: - https://github.com/UKGovernmentBEIS/beis-report-official-development-assistance/commit/e11a6fb1414a1978f9aaaae9640eed24cd0147e3 - https://github.com/dxw/dfsseta-apply-for-landing-ruby/commit/dbe1ffb80da6216e9c35e2d0917d676e0a428914 The following is printed in the console before the error and backtrace: ``` Please, set config.cache_classes to false in config/environments/test.rb. ``` --- config/environments/test.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/environments/test.rb b/config/environments/test.rb index 8f360510..a62b9218 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -10,7 +10,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 From d486b164b936e28a9058e76d6903b6cfc58fde3f Mon Sep 17 00:00:00 2001 From: Ynda Jas Date: Wed, 26 Jun 2024 13:54:45 +0100 Subject: [PATCH 2/6] Upgrade Rails defaults to 7.0 This fixes a deprecation warning and follows the linked guidance: ``` DEPRECATION WARNING: Support for `config.active_support.cache_format_version = 6.1` has been deprecated and will be removed in Rails 7.2. Check the Rails upgrade guide at https://guides.rubyonrails.org/upgrading_ruby_on_rails.html#new-activesupport-cache-serialization-format for more information on how to upgrade. ``` --- config/application.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/application.rb b/config/application.rb index 8cc9abfa..82293c1c 100644 --- a/config/application.rb +++ b/config/application.rb @@ -23,7 +23,7 @@ class Application < Rails::Application end # Initialize configuration defaults for originally generated Rails version. - config.load_defaults 6.0 + config.load_defaults 7.0 # Configuration for the application, engines, and railties goes here. # From 41a17d2dcd2017f9b4303e26472afbbe31ce7e05 Mon Sep 17 00:00:00 2001 From: Ynda Jas Date: Wed, 26 Jun 2024 13:57:49 +0100 Subject: [PATCH 3/6] Upgrade Puma from 5.6+ to 6.4+ This fixes an error when trying to drop the database locally: ``` /Users/ynda/code/github.com/dxw/rails-template/vendor/bundle/ruby/3.3.0/gems/puma-5.6.8/lib/rack/version_restriction.rb:12:in `
': Puma 5 is not compatible with Rack 3, please upgrade to Puma 6 or higher. (StandardError) ``` We're already on 6.4 in the DfSSETA example app and RODA --- Gemfile | 2 +- Gemfile.lock | 61 +++++++++++++++++++++++++++++++--------------------- 2 files changed, 37 insertions(+), 26 deletions(-) diff --git a/Gemfile b/Gemfile index ee7d3825..637e93b3 100644 --- a/Gemfile +++ b/Gemfile @@ -14,7 +14,7 @@ gem "lograge", "~> 0.12" gem "pg" gem "pry-rails" gem "mini_racer" -gem "puma", "~> 5.6" +gem "puma", "~> 6.4" gem "rollbar" gem "rails", "~> 7.0" gem "sass-rails", "~> 6.0" diff --git a/Gemfile.lock b/Gemfile.lock index 3bad3e1f..d7ec6a3a 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -93,7 +93,7 @@ GEM autoprefixer-rails (>= 9.1.0) popper_js (>= 2.11.8, < 3) brakeman (5.4.1) - builder (3.2.4) + builder (3.3.0) bullet (7.1.6) activesupport (>= 3.0.0) uniform_notifier (~> 1.11) @@ -133,7 +133,7 @@ GEM dotenv (= 2.8.1) railties (>= 3.2) drb (2.2.1) - erubi (1.12.0) + erubi (1.13.0) execjs (2.9.1) factory_bot (6.4.5) activesupport (>= 5.0.0) @@ -148,7 +148,10 @@ GEM high_voltage (3.1.2) i18n (1.14.5) concurrent-ruby (~> 1.0) - irb (0.9.6) + io-console (0.7.2) + irb (1.13.2) + rdoc (>= 4.0.0) + reline (>= 0.4.2) jbuilder (2.12.0) actionview (>= 5.0.0) activesupport (>= 5.0.0) @@ -187,7 +190,7 @@ GEM mini_mime (1.1.5) mini_racer (0.6.4) libv8-node (~> 16.19.0.0) - minitest (5.22.3) + minitest (5.24.0) msgpack (1.7.2) mutex_m (0.2.0) net-imap (0.4.13) @@ -217,18 +220,20 @@ GEM method_source (~> 1.0) pry-rails (0.3.11) pry (>= 0.13.0) + psych (5.1.2) + stringio public_suffix (5.0.5) - puma (5.6.8) + puma (6.4.2) nio4r (~> 2.0) racc (1.8.0) - rack (2.2.9) - rack-session (1.0.2) - rack (< 3) + rack (3.1.4) + rack-session (2.0.0) + rack (>= 3.0.0) rack-test (2.1.0) rack (>= 1.3) - rackup (1.0.0) - rack (< 3) - webrick + rackup (2.1.0) + rack (>= 3) + webrick (~> 1.8) rails (7.1.3.4) actioncable (= 7.1.3.4) actionmailbox (= 7.1.3.4) @@ -260,34 +265,38 @@ GEM thor (~> 1.0, >= 1.2.2) zeitwerk (~> 2.6) rainbow (3.1.1) - rake (13.1.0) + rake (13.2.1) rb-fsevent (0.11.2) rb-inotify (0.10.1) ffi (~> 1.0) + rdoc (6.7.0) + psych (>= 4.0.0) regexp_parser (2.9.2) + reline (0.5.9) + io-console (~> 0.5) request_store (1.5.1) rack (>= 1.4) rexml (3.3.1) strscan rollbar (3.5.2) rouge (1.11.1) - rspec-core (3.12.3) - rspec-support (~> 3.12.0) - rspec-expectations (3.12.4) + rspec-core (3.13.0) + rspec-support (~> 3.13.0) + rspec-expectations (3.13.1) diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.12.0) - rspec-mocks (3.12.7) + rspec-support (~> 3.13.0) + rspec-mocks (3.13.1) diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.12.0) - rspec-rails (6.1.1) + rspec-support (~> 3.13.0) + rspec-rails (6.1.3) actionpack (>= 6.1) activesupport (>= 6.1) railties (>= 6.1) - rspec-core (~> 3.12) - rspec-expectations (~> 3.12) - rspec-mocks (~> 3.12) - rspec-support (~> 3.12) - rspec-support (3.12.2) + rspec-core (~> 3.13) + rspec-expectations (~> 3.13) + rspec-mocks (~> 3.13) + rspec-support (~> 3.13) + rspec-support (3.13.1) rubocop (1.64.1) json (~> 2.3) language_server-protocol (>= 3.17.0) @@ -350,6 +359,7 @@ GEM standard-performance (1.4.0) lint_roller (~> 1.1) rubocop-performance (~> 1.21.0) + stringio (3.1.1) strscan (3.1.0) thor (1.3.1) tilt (2.3.0) @@ -379,6 +389,7 @@ GEM PLATFORMS arm64-darwin-22 + arm64-darwin-23 x86_64-darwin-21 x86_64-linux @@ -405,7 +416,7 @@ DEPENDENCIES mini_racer pg pry-rails - puma (~> 5.6) + puma (~> 6.4) rails (~> 7.0) rails_layout rollbar From b6022cd4c9e5cdb13e01d51b584a4800bf5606f9 Mon Sep 17 00:00:00 2001 From: Ynda Jas Date: Wed, 26 Jun 2024 14:06:44 +0100 Subject: [PATCH 4/6] Ignore `.ruby-lsp/**.*` in Prettier I think this folder is generated and used by a VS Code extension (it's not visible in the VS Code file explorer) and doesn't show up in git (without being mentioned in `.gitignore`) --- .prettierignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.prettierignore b/.prettierignore index 6b4ccafc..6a867226 100644 --- a/.prettierignore +++ b/.prettierignore @@ -26,3 +26,4 @@ *.gz /public/assets/* /coverage +.ruby-lsp/ From 7bed0983d223eab1bcee71355222a07027f53c5a Mon Sep 17 00:00:00 2001 From: Ynda Jas Date: Wed, 26 Jun 2024 14:21:45 +0100 Subject: [PATCH 5/6] Fix `read` without variable error The shellcheck exits with the following message without this: ``` In script/no-docker/setup line 27: read -r ^--^ SC3061 (warning): In POSIX sh, read without a variable is undefined. In script/no-docker/setup line 49: read -r ^--^ SC3061 (warning): In POSIX sh, read without a variable is undefined. ``` Typically `read` without a variable implicitly assigns the user input to `$REPLY`, but because we're using `#!/bin/sh` (not Bash) we need to provide a variable name explicitly --- script/no-docker/setup | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/script/no-docker/setup b/script/no-docker/setup index e6a45d22..6cd38416 100755 --- a/script/no-docker/setup +++ b/script/no-docker/setup @@ -24,7 +24,7 @@ set -e if [ -z "$CI" ] && [ "$DB_DROP_RESULT" != 0 ]; then printf "\\nDatabase drop failed. Continue anyway? [y/N] " - read -r + read -r REPLY case $REPLY in y | Y) @@ -46,7 +46,7 @@ set -e if [ -z "$CI" ] && [ "$DB_DROP_RESULT" != 0 ]; then printf "\\nDatabase drop failed. Continue anyway? [y/N] " - read -r + read -r REPLY case $REPLY in y | Y) From b2ce561d935afad98fb0d1afcd018f633d18107d Mon Sep 17 00:00:00 2001 From: Ynda Jas Date: Wed, 26 Jun 2024 14:59:37 +0100 Subject: [PATCH 6/6] Fix `fixture_path` deprecation warning This is now plural ``` Rails 7.1 has deprecated the singular fixture_path in favour of an array.You should migrate to plural: ``` --- spec/rails_helper.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb index 90ad2e45..dddc24fa 100644 --- a/spec/rails_helper.rb +++ b/spec/rails_helper.rb @@ -34,7 +34,7 @@ end RSpec.configure do |config| # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures - config.fixture_path = "#{::Rails.root}/spec/fixtures" + config.fixture_paths = ["#{::Rails.root}/spec/fixtures"] # If you're not using ActiveRecord, or you'd prefer not to run each of your # examples within a transaction, remove the following line or assign false