From a65ae57020fe4a94ad9f64771124c29aa085d8f4 Mon Sep 17 00:00:00 2001 From: Fabio Lima Date: Sun, 15 Jun 2025 10:00:21 -0700 Subject: [PATCH 01/19] Remove deprecated version from docker-compose --- docker-compose.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/docker-compose.yml b/docker-compose.yml index d1c48363..6f819bec 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -7,7 +7,6 @@ # docker-compose build # docker-compose run --rm web bin/setup # docker-compose up -version: "3" x-app: &app build: From 68adcaeca7fa9e56660917ce13ec0c71cb308c11 Mon Sep 17 00:00:00 2001 From: Fabio Lima Date: Sun, 15 Jun 2025 11:10:20 -0700 Subject: [PATCH 02/19] Fix crash when attempting to bundle install --- Gemfile.lock | 421 +++++++++++++++++++++++++++++---------------------- 1 file changed, 239 insertions(+), 182 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 033da032..c1e42e57 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -7,90 +7,90 @@ GIT GEM remote: https://rubygems.org/ specs: - actioncable (7.0.8.4) - actionpack (= 7.0.8.4) - activesupport (= 7.0.8.4) + actioncable (7.0.8.7) + actionpack (= 7.0.8.7) + activesupport (= 7.0.8.7) nio4r (~> 2.0) websocket-driver (>= 0.6.1) - actionmailbox (7.0.8.4) - actionpack (= 7.0.8.4) - activejob (= 7.0.8.4) - activerecord (= 7.0.8.4) - activestorage (= 7.0.8.4) - activesupport (= 7.0.8.4) + actionmailbox (7.0.8.7) + actionpack (= 7.0.8.7) + activejob (= 7.0.8.7) + activerecord (= 7.0.8.7) + activestorage (= 7.0.8.7) + activesupport (= 7.0.8.7) mail (>= 2.7.1) net-imap net-pop net-smtp - actionmailer (7.0.8.4) - actionpack (= 7.0.8.4) - actionview (= 7.0.8.4) - activejob (= 7.0.8.4) - activesupport (= 7.0.8.4) + actionmailer (7.0.8.7) + actionpack (= 7.0.8.7) + actionview (= 7.0.8.7) + activejob (= 7.0.8.7) + activesupport (= 7.0.8.7) mail (~> 2.5, >= 2.5.4) net-imap net-pop net-smtp rails-dom-testing (~> 2.0) - actionpack (7.0.8.4) - actionview (= 7.0.8.4) - activesupport (= 7.0.8.4) + actionpack (7.0.8.7) + actionview (= 7.0.8.7) + activesupport (= 7.0.8.7) 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 (7.0.8.4) - actionpack (= 7.0.8.4) - activerecord (= 7.0.8.4) - activestorage (= 7.0.8.4) - activesupport (= 7.0.8.4) + actiontext (7.0.8.7) + actionpack (= 7.0.8.7) + activerecord (= 7.0.8.7) + activestorage (= 7.0.8.7) + activesupport (= 7.0.8.7) globalid (>= 0.6.0) nokogiri (>= 1.8.5) - actionview (7.0.8.4) - activesupport (= 7.0.8.4) + actionview (7.0.8.7) + activesupport (= 7.0.8.7) builder (~> 3.1) erubi (~> 1.4) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.1, >= 1.2.0) - activejob (7.0.8.4) - activesupport (= 7.0.8.4) + activejob (7.0.8.7) + activesupport (= 7.0.8.7) globalid (>= 0.3.6) - activemodel (7.0.8.4) - activesupport (= 7.0.8.4) - activerecord (7.0.8.4) - activemodel (= 7.0.8.4) - activesupport (= 7.0.8.4) - activestorage (7.0.8.4) - actionpack (= 7.0.8.4) - activejob (= 7.0.8.4) - activerecord (= 7.0.8.4) - activesupport (= 7.0.8.4) + activemodel (7.0.8.7) + activesupport (= 7.0.8.7) + activerecord (7.0.8.7) + activemodel (= 7.0.8.7) + activesupport (= 7.0.8.7) + activestorage (7.0.8.7) + actionpack (= 7.0.8.7) + activejob (= 7.0.8.7) + activerecord (= 7.0.8.7) + activesupport (= 7.0.8.7) marcel (~> 1.0) mini_mime (>= 1.1.0) - activesupport (7.0.8.4) + activesupport (7.0.8.7) concurrent-ruby (~> 1.0, >= 1.0.2) i18n (>= 1.6, < 2) minitest (>= 5.1) tzinfo (~> 2.0) - addressable (2.8.6) - public_suffix (>= 2.0.2, < 6.0) - ast (2.4.2) - base64 (0.2.0) + addressable (2.8.7) + public_suffix (>= 2.0.2, < 7.0) + ast (2.4.3) + base64 (0.3.0) bcrypt (3.1.20) better_errors (2.10.1) erubi (>= 1.0.0) rack (>= 0.9.0) rouge (>= 1.0.0) - bigdecimal (3.1.8) + bigdecimal (3.2.2) bindex (0.8.1) binding_of_caller (1.0.1) debug_inspector (>= 1.2.0) - bootsnap (1.18.3) + bootsnap (1.18.6) msgpack (~> 1.2) - brakeman (6.1.2) + brakeman (7.0.2) racc builder (3.3.0) - byebug (11.1.3) + byebug (12.0.0) capybara (3.40.0) addressable matrix @@ -102,68 +102,95 @@ GEM xpath (~> 3.2) coderay (1.1.3) colorize (1.1.0) - concurrent-ruby (1.3.4) - connection_pool (2.4.1) + concurrent-ruby (1.3.5) + connection_pool (2.5.3) crass (1.0.6) - cssbundling-rails (1.4.0) + cssbundling-rails (1.4.3) railties (>= 6.0.0) - dartsass-sprockets (3.1.0) + csv (3.3.5) + dartsass-sprockets (3.2.1) railties (>= 4.0.0) - sassc-embedded (~> 1.69) + sassc-embedded (~> 1.80.1) sprockets (> 3.0) sprockets-rails tilt - date (3.3.4) + date (3.4.1) debug_inspector (1.2.0) - devise (4.9.3) + devise (4.9.4) bcrypt (~> 3.0) orm_adapter (~> 0.1) railties (>= 4.1.0) responders warden (~> 1.2.3) - diff-lcs (1.5.1) - dotenv (3.1.0) - dotenv-rails (3.1.0) - dotenv (= 3.1.0) + diff-lcs (1.6.2) + dotenv (3.1.8) + dotenv-rails (3.1.8) + dotenv (= 3.1.8) railties (>= 6.1) - erubi (1.13.0) - factory_bot (6.4.6) - activesupport (>= 5.0.0) - factory_bot_rails (6.4.3) - factory_bot (~> 6.4) + erubi (1.13.1) + factory_bot (6.5.4) + activesupport (>= 6.1.0) + factory_bot_rails (6.4.4) + factory_bot (~> 6.5) railties (>= 5.0.0) faker (3.4.2) i18n (>= 1.8.11, < 2) - ffi (1.16.3) + ffi (1.17.2-aarch64-linux-gnu) + ffi (1.17.2-aarch64-linux-musl) + ffi (1.17.2-arm-linux-gnu) + ffi (1.17.2-arm-linux-musl) + ffi (1.17.2-arm64-darwin) + ffi (1.17.2-x86_64-darwin) + ffi (1.17.2-x86_64-linux-gnu) + ffi (1.17.2-x86_64-linux-musl) geo_coord (0.2.0) - geocoder (1.8.2) + geocoder (1.8.5) + base64 (>= 0.1.0) + csv (>= 3.0.0) globalid (1.2.1) activesupport (>= 6.1) - google-protobuf (4.27.3-x86_64-darwin) + google-protobuf (4.31.1) + bigdecimal + rake (>= 13) + google-protobuf (4.31.1-aarch64-linux-gnu) + bigdecimal + rake (>= 13) + google-protobuf (4.31.1-aarch64-linux-musl) + bigdecimal + rake (>= 13) + google-protobuf (4.31.1-arm64-darwin) + bigdecimal + rake (>= 13) + google-protobuf (4.31.1-x86_64-darwin) + bigdecimal + rake (>= 13) + google-protobuf (4.31.1-x86_64-linux-gnu) bigdecimal rake (>= 13) - google-protobuf (4.27.3-x86_64-linux) + google-protobuf (4.31.1-x86_64-linux-musl) bigdecimal rake (>= 13) hotwire-rails (0.1.3) rails (>= 6.0.0) stimulus-rails turbo-rails - i18n (1.14.5) + i18n (1.14.7) concurrent-ruby (~> 1.0) - inline_svg (1.9.0) + inline_svg (1.10.0) activesupport (>= 3.0) nokogiri (>= 1.6) jsbundling-rails (1.3.1) railties (>= 6.0.0) - json (2.7.2) - jwt (2.8.1) + json (2.12.2) + jwt (3.0.0) base64 - language_server-protocol (3.17.0.3) + language_server-protocol (3.17.0.5) + lint_roller (1.1.0) listen (3.9.0) rb-fsevent (~> 0.10, >= 0.10.3) rb-inotify (~> 0.9, >= 0.9.10) - loofah (2.22.0) + logger (1.7.0) + loofah (2.24.1) crass (~> 1.0.2) nokogiri (>= 1.12.0) mail (2.8.1) @@ -173,185 +200,208 @@ GEM net-smtp marcel (1.0.4) matrix (0.4.2) - memory_profiler (1.0.1) + memory_profiler (1.1.0) method_source (1.1.0) mini_mime (1.1.5) - minitest (5.25.1) - msgpack (1.7.2) - net-imap (0.4.10) + minitest (5.25.5) + msgpack (1.8.0) + net-imap (0.5.8) date net-protocol net-pop (0.1.2) net-protocol net-protocol (0.2.2) timeout - net-smtp (0.4.0.1) + net-smtp (0.5.1) net-protocol - nio4r (2.7.0) - nokogiri (1.16.7-x86_64-darwin) + nio4r (2.7.4) + nokogiri (1.18.8-aarch64-linux-gnu) racc (~> 1.4) - nokogiri (1.16.7-x86_64-linux) + nokogiri (1.18.8-aarch64-linux-musl) + racc (~> 1.4) + nokogiri (1.18.8-arm-linux-gnu) + racc (~> 1.4) + nokogiri (1.18.8-arm-linux-musl) + racc (~> 1.4) + nokogiri (1.18.8-arm64-darwin) + racc (~> 1.4) + nokogiri (1.18.8-x86_64-darwin) + racc (~> 1.4) + nokogiri (1.18.8-x86_64-linux-gnu) + racc (~> 1.4) + nokogiri (1.18.8-x86_64-linux-musl) racc (~> 1.4) orm_adapter (0.5.0) - pagy (7.0.10) - parallel (1.26.3) - parser (3.3.4.2) + pagy (7.0.11) + parallel (1.27.0) + parser (3.3.8.0) ast (~> 2.4.1) racc - pg (1.5.6) + pg (1.5.9) + prism (1.4.0) pry (0.14.2) coderay (~> 1.1) method_source (~> 1.0) - pry-byebug (3.10.1) - byebug (~> 11.0) - pry (>= 0.13, < 0.15) - pry-rails (0.3.9) - pry (>= 0.10.4) + pry-byebug (3.11.0) + byebug (~> 12.0) + pry (>= 0.13, < 0.16) + pry-rails (0.3.11) + pry (>= 0.13.0) pry-remote (0.1.8) pry (~> 0.9) slop (~> 3.0) pry-stack_explorer (0.6.1) binding_of_caller (~> 1.0) pry (~> 0.13) - public_suffix (5.0.4) - puma (6.4.2) + public_suffix (6.0.2) + puma (6.4.3) nio4r (~> 2.0) racc (1.8.1) - rack (2.2.9) + rack (2.2.17) rack-cors (2.0.2) rack (>= 2.0.0) rack-mini-profiler (3.3.1) rack (>= 1.2.0) - rack-test (2.1.0) + rack-test (2.2.0) rack (>= 1.3) - rails (7.0.8.4) - actioncable (= 7.0.8.4) - actionmailbox (= 7.0.8.4) - actionmailer (= 7.0.8.4) - actionpack (= 7.0.8.4) - actiontext (= 7.0.8.4) - actionview (= 7.0.8.4) - activejob (= 7.0.8.4) - activemodel (= 7.0.8.4) - activerecord (= 7.0.8.4) - activestorage (= 7.0.8.4) - activesupport (= 7.0.8.4) + rails (7.0.8.7) + actioncable (= 7.0.8.7) + actionmailbox (= 7.0.8.7) + actionmailer (= 7.0.8.7) + actionpack (= 7.0.8.7) + actiontext (= 7.0.8.7) + actionview (= 7.0.8.7) + activejob (= 7.0.8.7) + activemodel (= 7.0.8.7) + activerecord (= 7.0.8.7) + activestorage (= 7.0.8.7) + activesupport (= 7.0.8.7) bundler (>= 1.15.0) - railties (= 7.0.8.4) - rails-dom-testing (2.2.0) + railties (= 7.0.8.7) + rails-dom-testing (2.3.0) activesupport (>= 5.0.0) minitest nokogiri (>= 1.6) - rails-html-sanitizer (1.6.0) + rails-html-sanitizer (1.6.2) loofah (~> 2.21) - nokogiri (~> 1.14) - railties (7.0.8.4) - actionpack (= 7.0.8.4) - activesupport (= 7.0.8.4) + nokogiri (>= 1.15.7, != 1.16.7, != 1.16.6, != 1.16.5, != 1.16.4, != 1.16.3, != 1.16.2, != 1.16.1, != 1.16.0.rc1, != 1.16.0) + railties (7.0.8.7) + actionpack (= 7.0.8.7) + activesupport (= 7.0.8.7) method_source rake (>= 12.2) thor (~> 1.0) zeitwerk (~> 2.5) rainbow (3.1.1) - rake (13.2.1) + rake (13.3.0) rb-fsevent (0.11.2) - rb-inotify (0.10.1) + rb-inotify (0.11.1) ffi (~> 1.0) redis (5.1.0) redis-client (>= 0.17.0) - redis-client (0.21.0) + redis-client (0.24.0) connection_pool - regexp_parser (2.9.2) - requestjs-rails (0.0.11) + regexp_parser (2.10.0) + requestjs-rails (0.0.12) railties (>= 6.1.0) responders (3.1.1) actionpack (>= 5.2) railties (>= 5.2) - rexml (3.3.5) - strscan - rouge (4.2.0) - rspec-core (3.13.0) + rouge (4.5.2) + rspec-core (3.13.4) rspec-support (~> 3.13.0) - rspec-expectations (3.13.0) + rspec-expectations (3.13.5) diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.13.0) - rspec-mocks (3.13.0) + rspec-mocks (3.13.5) diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.13.0) - rspec-rails (6.1.1) + rspec-rails (6.1.5) 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.13.1) - rubocop (1.65.1) + rspec-core (~> 3.13) + rspec-expectations (~> 3.13) + rspec-mocks (~> 3.13) + rspec-support (~> 3.13) + rspec-support (3.13.4) + rubocop (1.76.1) json (~> 2.3) - language_server-protocol (>= 3.17.0) + language_server-protocol (~> 3.17.0.2) + lint_roller (~> 1.1.0) parallel (~> 1.10) parser (>= 3.3.0.2) rainbow (>= 2.2.2, < 4.0) - regexp_parser (>= 2.4, < 3.0) - rexml (>= 3.2.5, < 4.0) - rubocop-ast (>= 1.31.1, < 2.0) + regexp_parser (>= 2.9.3, < 3.0) + rubocop-ast (>= 1.45.0, < 2.0) ruby-progressbar (~> 1.7) - unicode-display_width (>= 2.4.0, < 3.0) - rubocop-ast (1.32.1) - parser (>= 3.3.1.0) - rubocop-capybara (2.20.0) - rubocop (~> 1.41) - rubocop-factory_bot (2.25.1) - rubocop (~> 1.41) - rubocop-packaging (0.5.2) - rubocop (>= 1.33, < 2.0) - rubocop-performance (1.21.1) - rubocop (>= 1.48.1, < 2.0) - rubocop-ast (>= 1.31.1, < 2.0) - rubocop-rails (2.24.0) + unicode-display_width (>= 2.4.0, < 4.0) + rubocop-ast (1.45.1) + parser (>= 3.3.7.2) + prism (~> 1.4) + rubocop-packaging (0.6.0) + lint_roller (~> 1.1.0) + rubocop (>= 1.72.1, < 2.0) + rubocop-performance (1.25.0) + lint_roller (~> 1.1) + rubocop (>= 1.75.0, < 2.0) + rubocop-ast (>= 1.38.0, < 2.0) + rubocop-rails (2.32.0) activesupport (>= 4.2.0) + lint_roller (~> 1.1) rack (>= 1.1) - rubocop (>= 1.33.0, < 2.0) - rubocop-ast (>= 1.31.1, < 2.0) - rubocop-rspec (2.27.1) - rubocop (~> 1.40) - rubocop-capybara (~> 2.17) - rubocop-factory_bot (~> 2.22) + rubocop (>= 1.75.0, < 2.0) + rubocop-ast (>= 1.44.0, < 2.0) + rubocop-rspec (3.6.0) + lint_roller (~> 1.1) + rubocop (~> 1.72, >= 1.72.1) ruby-progressbar (1.13.0) - sass-embedded (1.77.8-x86_64-darwin) - google-protobuf (~> 4.26) - sass-embedded (1.77.8-x86_64-linux-gnu) - google-protobuf (~> 4.26) - sassc-embedded (1.77.8) - sass-embedded (~> 1.77) - shoulda-matchers (6.4.0) + sass-embedded (1.89.2-aarch64-linux-gnu) + google-protobuf (~> 4.31) + sass-embedded (1.89.2-aarch64-linux-musl) + google-protobuf (~> 4.31) + sass-embedded (1.89.2-arm-linux-gnueabihf) + google-protobuf (~> 4.31) + sass-embedded (1.89.2-arm-linux-musleabihf) + google-protobuf (~> 4.31) + sass-embedded (1.89.2-arm64-darwin) + google-protobuf (~> 4.31) + sass-embedded (1.89.2-x86_64-darwin) + google-protobuf (~> 4.31) + sass-embedded (1.89.2-x86_64-linux-gnu) + google-protobuf (~> 4.31) + sass-embedded (1.89.2-x86_64-linux-musl) + google-protobuf (~> 4.31) + sassc-embedded (1.80.4) + sass-embedded (~> 1.80) + shoulda-matchers (6.5.0) activesupport (>= 5.2.0) slop (3.6.0) - sprockets (4.2.1) + sprockets (4.2.2) concurrent-ruby (~> 1.0) + logger rack (>= 2.2.4, < 4) - sprockets-rails (3.4.2) - actionpack (>= 5.2) - activesupport (>= 5.2) + sprockets-rails (3.5.2) + actionpack (>= 6.1) + activesupport (>= 6.1) sprockets (>= 3.0.0) - stackprof (0.2.26) - stimulus-rails (1.3.3) + stackprof (0.2.27) + stimulus-rails (1.3.4) railties (>= 6.0.0) - strscan (3.1.0) - thor (1.3.1) - tilt (2.3.0) - timeout (0.4.1) - turbo-rails (2.0.5) + thor (1.3.2) + tilt (2.6.0) + timeout (0.4.3) + turbo-rails (2.0.12) actionpack (>= 6.0.0) - activejob (>= 6.0.0) railties (>= 6.0.0) tzinfo (2.0.6) concurrent-ruby (~> 1.0) - unicode-display_width (2.5.0) - view_component (3.11.0) - activesupport (>= 5.2.0, < 8.0) - concurrent-ruby (~> 1.0) + unicode-display_width (3.1.4) + unicode-emoji (~> 4.0, >= 4.0.4) + unicode-emoji (4.0.4) + view_component (3.23.2) + activesupport (>= 5.2.0, < 8.1) + concurrent-ruby (~> 1) method_source (~> 1.0) warden (1.2.9) rack (>= 2.0.9) @@ -360,18 +410,25 @@ GEM activemodel (>= 6.0.0) bindex (>= 0.4.0) railties (>= 6.0.0) - websocket-driver (0.7.6) + websocket-driver (0.8.0) + base64 websocket-extensions (>= 0.1.0) websocket-extensions (0.1.5) xpath (3.2.0) nokogiri (~> 1.8) - zeitwerk (2.6.17) + zeitwerk (2.7.3) PLATFORMS - x86_64-darwin-21 - x86_64-darwin-22 - x86_64-darwin-23 - x86_64-linux + aarch64-linux-gnu + aarch64-linux-musl + arm-linux-gnu + arm-linux-gnueabihf + arm-linux-musl + arm-linux-musleabihf + arm64-darwin + x86_64-darwin + x86_64-linux-gnu + x86_64-linux-musl DEPENDENCIES bcrypt (~> 3.1.16) @@ -427,4 +484,4 @@ RUBY VERSION ruby 3.2.3p157 BUNDLED WITH - 2.5.6 + 2.6.9 From e12b5a69890e6b3b6dc006fca1202f2b24354ca9 Mon Sep 17 00:00:00 2001 From: Fabio Lima Date: Sun, 15 Jun 2025 11:41:25 -0700 Subject: [PATCH 03/19] Upgrade Rails to 7.1.0 and update related dependencies; enhance development and production configurations. --- Gemfile | 2 +- Gemfile.lock | 187 +++++++----- config/application.rb | 5 + config/environments/development.rb | 8 +- config/environments/production.rb | 47 +-- config/environments/test.rb | 18 +- config/initializers/action_text.rb | 2 +- .../initializers/content_security_policy.rb | 13 +- config/initializers/cors.rb | 2 +- .../initializers/filter_parameter_logging.rb | 6 +- .../new_framework_defaults_7_1.rb | 280 ++++++++++++++++++ config/initializers/permissions_policy.rb | 20 +- 12 files changed, 466 insertions(+), 124 deletions(-) create mode 100644 config/initializers/new_framework_defaults_7_1.rb diff --git a/Gemfile b/Gemfile index 9faed820..03d0af9b 100644 --- a/Gemfile +++ b/Gemfile @@ -4,7 +4,7 @@ git_source(:github) { |repo| "https://github.com/#{repo}.git" } ruby "3.2.3" # Bundle edge Rails instead: gem "rails", github: "rails/rails" -gem "rails", "~> 7.0.8" +gem "rails", "~> 7.1.0" # Use postgresql as the database for Active Record gem "pg", "~> 1.5.6" # Use Puma as the app server diff --git a/Gemfile.lock b/Gemfile.lock index c1e42e57..ae2f651b 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -7,76 +7,89 @@ GIT GEM remote: https://rubygems.org/ specs: - actioncable (7.0.8.7) - actionpack (= 7.0.8.7) - activesupport (= 7.0.8.7) + actioncable (7.1.5.1) + actionpack (= 7.1.5.1) + activesupport (= 7.1.5.1) nio4r (~> 2.0) websocket-driver (>= 0.6.1) - actionmailbox (7.0.8.7) - actionpack (= 7.0.8.7) - activejob (= 7.0.8.7) - activerecord (= 7.0.8.7) - activestorage (= 7.0.8.7) - activesupport (= 7.0.8.7) + zeitwerk (~> 2.6) + actionmailbox (7.1.5.1) + actionpack (= 7.1.5.1) + activejob (= 7.1.5.1) + activerecord (= 7.1.5.1) + activestorage (= 7.1.5.1) + activesupport (= 7.1.5.1) mail (>= 2.7.1) net-imap net-pop net-smtp - actionmailer (7.0.8.7) - actionpack (= 7.0.8.7) - actionview (= 7.0.8.7) - activejob (= 7.0.8.7) - activesupport (= 7.0.8.7) + actionmailer (7.1.5.1) + actionpack (= 7.1.5.1) + actionview (= 7.1.5.1) + activejob (= 7.1.5.1) + activesupport (= 7.1.5.1) mail (~> 2.5, >= 2.5.4) net-imap net-pop net-smtp - rails-dom-testing (~> 2.0) - actionpack (7.0.8.7) - actionview (= 7.0.8.7) - activesupport (= 7.0.8.7) - rack (~> 2.0, >= 2.2.4) + rails-dom-testing (~> 2.2) + actionpack (7.1.5.1) + actionview (= 7.1.5.1) + activesupport (= 7.1.5.1) + nokogiri (>= 1.8.5) + racc + rack (>= 2.2.4) + rack-session (>= 1.0.1) rack-test (>= 0.6.3) - rails-dom-testing (~> 2.0) - rails-html-sanitizer (~> 1.0, >= 1.2.0) - actiontext (7.0.8.7) - actionpack (= 7.0.8.7) - activerecord (= 7.0.8.7) - activestorage (= 7.0.8.7) - activesupport (= 7.0.8.7) + rails-dom-testing (~> 2.2) + rails-html-sanitizer (~> 1.6) + actiontext (7.1.5.1) + actionpack (= 7.1.5.1) + activerecord (= 7.1.5.1) + activestorage (= 7.1.5.1) + activesupport (= 7.1.5.1) globalid (>= 0.6.0) nokogiri (>= 1.8.5) - actionview (7.0.8.7) - activesupport (= 7.0.8.7) + actionview (7.1.5.1) + activesupport (= 7.1.5.1) builder (~> 3.1) - erubi (~> 1.4) - rails-dom-testing (~> 2.0) - rails-html-sanitizer (~> 1.1, >= 1.2.0) - activejob (7.0.8.7) - activesupport (= 7.0.8.7) + erubi (~> 1.11) + rails-dom-testing (~> 2.2) + rails-html-sanitizer (~> 1.6) + activejob (7.1.5.1) + activesupport (= 7.1.5.1) globalid (>= 0.3.6) - activemodel (7.0.8.7) - activesupport (= 7.0.8.7) - activerecord (7.0.8.7) - activemodel (= 7.0.8.7) - activesupport (= 7.0.8.7) - activestorage (7.0.8.7) - actionpack (= 7.0.8.7) - activejob (= 7.0.8.7) - activerecord (= 7.0.8.7) - activesupport (= 7.0.8.7) + activemodel (7.1.5.1) + activesupport (= 7.1.5.1) + activerecord (7.1.5.1) + activemodel (= 7.1.5.1) + activesupport (= 7.1.5.1) + timeout (>= 0.4.0) + activestorage (7.1.5.1) + actionpack (= 7.1.5.1) + activejob (= 7.1.5.1) + activerecord (= 7.1.5.1) + activesupport (= 7.1.5.1) marcel (~> 1.0) - mini_mime (>= 1.1.0) - activesupport (7.0.8.7) + activesupport (7.1.5.1) + base64 + benchmark (>= 0.3) + bigdecimal concurrent-ruby (~> 1.0, >= 1.0.2) + 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) addressable (2.8.7) public_suffix (>= 2.0.2, < 7.0) ast (2.4.3) base64 (0.3.0) bcrypt (3.1.20) + benchmark (0.4.1) better_errors (2.10.1) erubi (>= 1.0.0) rack (>= 0.9.0) @@ -127,6 +140,8 @@ GEM dotenv-rails (3.1.8) dotenv (= 3.1.8) railties (>= 6.1) + drb (2.2.3) + erb (5.0.1) erubi (1.13.1) factory_bot (6.5.4) activesupport (>= 6.1.0) @@ -179,6 +194,11 @@ GEM inline_svg (1.10.0) activesupport (>= 3.0) nokogiri (>= 1.6) + io-console (0.8.0) + irb (1.15.2) + pp (>= 0.6.0) + rdoc (>= 4.0.0) + reline (>= 0.4.2) jsbundling-rails (1.3.1) railties (>= 6.0.0) json (2.12.2) @@ -205,6 +225,7 @@ GEM mini_mime (1.1.5) minitest (5.25.5) msgpack (1.8.0) + mutex_m (0.3.0) net-imap (0.5.8) date net-protocol @@ -238,6 +259,9 @@ GEM ast (~> 2.4.1) racc pg (1.5.9) + pp (0.6.2) + prettyprint + prettyprint (0.2.0) prism (1.4.0) pry (0.14.2) coderay (~> 1.1) @@ -253,31 +277,40 @@ GEM pry-stack_explorer (0.6.1) binding_of_caller (~> 1.0) pry (~> 0.13) + psych (5.2.6) + date + stringio public_suffix (6.0.2) puma (6.4.3) nio4r (~> 2.0) racc (1.8.1) - rack (2.2.17) - rack-cors (2.0.2) - rack (>= 2.0.0) + rack (3.1.16) + rack-cors (3.0.0) + logger + rack (>= 3.0.14) rack-mini-profiler (3.3.1) rack (>= 1.2.0) + rack-session (2.1.1) + base64 (>= 0.1.0) + rack (>= 3.0.0) rack-test (2.2.0) rack (>= 1.3) - rails (7.0.8.7) - actioncable (= 7.0.8.7) - actionmailbox (= 7.0.8.7) - actionmailer (= 7.0.8.7) - actionpack (= 7.0.8.7) - actiontext (= 7.0.8.7) - actionview (= 7.0.8.7) - activejob (= 7.0.8.7) - activemodel (= 7.0.8.7) - activerecord (= 7.0.8.7) - activestorage (= 7.0.8.7) - activesupport (= 7.0.8.7) + rackup (2.2.1) + rack (>= 3) + rails (7.1.5.1) + actioncable (= 7.1.5.1) + actionmailbox (= 7.1.5.1) + actionmailer (= 7.1.5.1) + actionpack (= 7.1.5.1) + actiontext (= 7.1.5.1) + actionview (= 7.1.5.1) + activejob (= 7.1.5.1) + activemodel (= 7.1.5.1) + activerecord (= 7.1.5.1) + activestorage (= 7.1.5.1) + activesupport (= 7.1.5.1) bundler (>= 1.15.0) - railties (= 7.0.8.7) + railties (= 7.1.5.1) rails-dom-testing (2.3.0) activesupport (>= 5.0.0) minitest @@ -285,25 +318,31 @@ GEM rails-html-sanitizer (1.6.2) loofah (~> 2.21) nokogiri (>= 1.15.7, != 1.16.7, != 1.16.6, != 1.16.5, != 1.16.4, != 1.16.3, != 1.16.2, != 1.16.1, != 1.16.0.rc1, != 1.16.0) - railties (7.0.8.7) - actionpack (= 7.0.8.7) - activesupport (= 7.0.8.7) - method_source + railties (7.1.5.1) + actionpack (= 7.1.5.1) + activesupport (= 7.1.5.1) + irb + rackup (>= 1.0.0) rake (>= 12.2) - thor (~> 1.0) - zeitwerk (~> 2.5) + thor (~> 1.0, >= 1.2.2) + zeitwerk (~> 2.6) rainbow (3.1.1) rake (13.3.0) rb-fsevent (0.11.2) rb-inotify (0.11.1) ffi (~> 1.0) + rdoc (6.14.0) + erb + psych (>= 4.0.0) redis (5.1.0) redis-client (>= 0.17.0) redis-client (0.24.0) connection_pool regexp_parser (2.10.0) - requestjs-rails (0.0.12) - railties (>= 6.1.0) + reline (0.6.1) + io-console (~> 0.5) + requestjs-rails (0.0.13) + railties (>= 7.1.0) responders (3.1.1) actionpack (>= 5.2) railties (>= 5.2) @@ -374,6 +413,7 @@ GEM google-protobuf (~> 4.31) sassc-embedded (1.80.4) sass-embedded (~> 1.80) + securerandom (0.4.1) shoulda-matchers (6.5.0) activesupport (>= 5.2.0) slop (3.6.0) @@ -388,12 +428,13 @@ GEM stackprof (0.2.27) stimulus-rails (1.3.4) railties (>= 6.0.0) + stringio (3.1.7) thor (1.3.2) tilt (2.6.0) timeout (0.4.3) - turbo-rails (2.0.12) - actionpack (>= 6.0.0) - railties (>= 6.0.0) + turbo-rails (2.0.16) + actionpack (>= 7.1.0) + railties (>= 7.1.0) tzinfo (2.0.6) concurrent-ruby (~> 1.0) unicode-display_width (3.1.4) @@ -463,7 +504,7 @@ DEPENDENCIES puma (~> 6.4.2) rack-cors rack-mini-profiler (~> 3.3.1) - rails (~> 7.0.8) + rails (~> 7.1.0) redis (~> 5.1.0) requestjs-rails rspec-rails (~> 6.1.1) diff --git a/config/application.rb b/config/application.rb index df498ec4..99534a23 100644 --- a/config/application.rb +++ b/config/application.rb @@ -11,6 +11,11 @@ class Application < Rails::Application # Initialize configuration defaults for originally generated Rails version. config.load_defaults 7.0 + # 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(assets tasks)) + # Configuration for the application, engines, and railties goes here. # # These settings can be overridden in specific environments using the files diff --git a/config/environments/development.rb b/config/environments/development.rb index 8500f459..2e7fb486 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -6,7 +6,7 @@ # In the development environment your application's code is reloaded any time # it changes. This slows down response time but is perfect for development # since you don't have to restart the web server when you make code changes. - config.cache_classes = false + config.enable_reloading = true # Do not eager load code on boot. config.eager_load = false @@ -56,6 +56,9 @@ # Highlight code that triggered database queries in logs. config.active_record.verbose_query_logs = true + # Highlight code that enqueued background job in logs. + config.active_job.verbose_enqueue_logs = true + # Suppress logger output for asset requests. config.assets.quiet = true @@ -67,4 +70,7 @@ # Uncomment if you wish to allow Action Cable access from any origin. # config.action_cable.disable_request_forgery_protection = true + + # Raise error when a before_action's only/except options reference missing actions + config.action_controller.raise_on_missing_callback_actions = true end diff --git a/config/environments/production.rb b/config/environments/production.rb index 3c6aee50..ae16020c 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -4,7 +4,7 @@ # Settings specified here will take precedence over those in config/application.rb. # Code is not reloaded between requests. - config.cache_classes = true + config.enable_reloading = false # Eager load code on boot. This eager loads most of Rails and # your application in memory, allowing both threaded web servers @@ -16,8 +16,8 @@ config.consider_all_requests_local = false config.action_controller.perform_caching = true - # Ensures that a master key has been made available in either ENV["RAILS_MASTER_KEY"] - # or in config/master.key. This key is used to decrypt credentials (and other encrypted files). + # Ensures that a master key has been made available in ENV["RAILS_MASTER_KEY"], config/master.key, or an environment + # key such as config/credentials/production.key. This key is used to decrypt credentials (and other encrypted files). # config.require_master_key = true # Disable serving static files from the `/public` folder by default since @@ -27,7 +27,7 @@ # Compress CSS using a preprocessor. # config.assets.css_compressor = :sass - # Do not fallback to assets pipeline if a precompiled asset is missed. + # Do not fall back to assets pipeline if a precompiled asset is missed. config.assets.compile = false # Enable serving of images, stylesheets, and JavaScripts from an asset server. @@ -45,16 +45,26 @@ # config.action_cable.url = "wss://example.com/cable" # config.action_cable.allowed_request_origins = [ "http://example.com", /http:\/\/example.*/ ] + # Assume all access to the app is happening through a SSL-terminating reverse proxy. + # Can be used together with config.force_ssl for Strict-Transport-Security and secure cookies. + # config.assume_ssl = true + # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. - # config.force_ssl = true + config.force_ssl = true - # Include generic and useful information about system operation, but avoid logging too much - # information to avoid inadvertent exposure of personally identifiable information (PII). - config.log_level = :info + # Log to STDOUT by default + config.logger = ActiveSupport::Logger.new(STDOUT) + .tap { |logger| logger.formatter = ::Logger::Formatter.new } + .then { |logger| ActiveSupport::TaggedLogging.new(logger) } # Prepend all log lines with the following tags. config.log_tags = [ :request_id ] + # "info" includes generic and useful information about system operation, but avoids logging too much + # information to avoid inadvertent exposure of personally identifiable information (PII). If you + # want to log everything, set the level to "debug". + config.log_level = ENV.fetch("RAILS_LOG_LEVEL", "info") + # Use a different cache store in production. # config.cache_store = :mem_cache_store @@ -75,19 +85,14 @@ # Don't log any deprecations. config.active_support.report_deprecations = false - # Use default logging formatter so that PID and timestamp are not suppressed. - config.log_formatter = ::Logger::Formatter.new - - # Use a different logger for distributed setups. - # require "syslog/logger" - # config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new "app-name") - - if ENV["RAILS_LOG_TO_STDOUT"].present? - logger = ActiveSupport::Logger.new(STDOUT) - logger.formatter = config.log_formatter - config.logger = ActiveSupport::TaggedLogging.new(logger) - end - # Do not dump schema after migrations. config.active_record.dump_schema_after_migration = false + + # Enable DNS rebinding protection and other `Host` header attacks. + # config.hosts = [ + # "example.com", # Allow requests from example.com + # /.*\.example\.com/ # Allow requests from subdomains like `www.example.com` + # ] + # Skip DNS rebinding protection for the default health check endpoint. + # config.host_authorization = { exclude: ->(request) { request.path == "/up" } } end diff --git a/config/environments/test.rb b/config/environments/test.rb index 6ea4d1e7..3e5ae7da 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -8,12 +8,13 @@ Rails.application.configure do # Settings specified here will take precedence over those in config/application.rb. - # Turn false under Spring and add config.action_view.cache_template_loading = true. - config.cache_classes = true + # While tests run files are not watched, reloading is not necessary. + config.enable_reloading = false - # Eager loading loads your whole application. When running a single test locally, - # this probably isn't necessary. It's a good idea to do in a continuous integration - # system, or in some way before deploying your code. + # Eager loading loads your entire application. When running a single test locally, + # this is usually not necessary, and can slow down your test suite. However, it's + # recommended that you enable it in continuous integration systems to ensure eager + # loading is working properly before deploying your code. config.eager_load = ENV["CI"].present? # Configure public file server for tests with Cache-Control for performance. @@ -27,8 +28,8 @@ config.action_controller.perform_caching = false config.cache_store = :null_store - # Raise exceptions instead of rendering exception templates. - config.action_dispatch.show_exceptions = false + # Render exception templates for rescuable exceptions and raise for other exceptions. + config.action_dispatch.show_exceptions = :rescuable # Disable request forgery protection in test environment. config.action_controller.allow_forgery_protection = false @@ -57,4 +58,7 @@ # 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 + config.action_controller.raise_on_missing_callback_actions = true end diff --git a/config/initializers/action_text.rb b/config/initializers/action_text.rb index 7f7ec239..0c74dfb0 100644 --- a/config/initializers/action_text.rb +++ b/config/initializers/action_text.rb @@ -1,4 +1,4 @@ Rails.application.config.after_initialize do # Sets ActionText to accept custom styling. - ActionText::ContentHelper.allowed_attributes.add 'style' + # ActionText::ContentHelper.allowed_attributes.add 'style' end diff --git a/config/initializers/content_security_policy.rb b/config/initializers/content_security_policy.rb index 3621f97f..b3076b38 100644 --- a/config/initializers/content_security_policy.rb +++ b/config/initializers/content_security_policy.rb @@ -1,8 +1,8 @@ # Be sure to restart your server when you modify this file. -# Define an application-wide content security policy -# For further information see the following documentation -# https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy +# Define an application-wide content security policy. +# See the Securing Rails Applications Guide for more information: +# https://guides.rubyonrails.org/security.html#content-security-policy-header # Rails.application.configure do # config.content_security_policy do |policy| @@ -16,11 +16,10 @@ # # policy.report_uri "/csp-violation-report-endpoint" # end # -# # Generate session nonces for permitted importmap and inline scripts +# # Generate session nonces for permitted importmap, inline scripts, and inline styles. # config.content_security_policy_nonce_generator = ->(request) { request.session.id.to_s } -# config.content_security_policy_nonce_directives = %w(script-src) +# config.content_security_policy_nonce_directives = %w(script-src style-src) # -# # Report CSP violations to a specified URI. See: -# # https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy-Report-Only +# # Report violations without enforcing the policy. # # config.content_security_policy_report_only = true # end diff --git a/config/initializers/cors.rb b/config/initializers/cors.rb index 5e4c830d..3fe955a2 100644 --- a/config/initializers/cors.rb +++ b/config/initializers/cors.rb @@ -1,7 +1,7 @@ # Be sure to restart your server when you modify this file. # Avoid CORS issues when API is called from the frontend app. -# Handle Cross-Origin Resource Sharing (CORS) in order to accept cross-origin AJAX requests. +# Handle Cross-Origin Resource Sharing (CORS) in order to accept cross-origin Ajax requests. # Read more: https://github.com/cyu/rack-cors diff --git a/config/initializers/filter_parameter_logging.rb b/config/initializers/filter_parameter_logging.rb index adc6568c..c2d89e28 100644 --- a/config/initializers/filter_parameter_logging.rb +++ b/config/initializers/filter_parameter_logging.rb @@ -1,8 +1,8 @@ # Be sure to restart your server when you modify this file. -# Configure parameters to be filtered from the log file. Use this to limit dissemination of -# sensitive information. See the ActiveSupport::ParameterFilter documentation for supported -# notations and behaviors. +# Configure parameters to be partially matched (e.g. passw matches password) and filtered from the log file. +# Use this to limit dissemination of sensitive information. +# See the ActiveSupport::ParameterFilter documentation for supported notations and behaviors. Rails.application.config.filter_parameters += [ :passw, :secret, :token, :_key, :crypt, :salt, :certificate, :otp, :ssn ] diff --git a/config/initializers/new_framework_defaults_7_1.rb b/config/initializers/new_framework_defaults_7_1.rb new file mode 100644 index 00000000..3dc295db --- /dev/null +++ b/config/initializers/new_framework_defaults_7_1.rb @@ -0,0 +1,280 @@ +# Be sure to restart your server when you modify this file. +# +# This file eases your Rails 7.1 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.1`. +# +# Read the Guide for Upgrading Ruby on Rails for more info on each option. +# https://guides.rubyonrails.org/upgrading_ruby_on_rails.html + +### +# No longer add autoloaded paths into `$LOAD_PATH`. This means that you won't be able +# to manually require files that are managed by the autoloader, which you shouldn't do anyway. +# +# This will reduce the size of the load path, making `require` faster if you don't use bootsnap, or reduce the size +# of the bootsnap cache if you use it. +# +# To set this configuration, add the following line to `config/application.rb` (NOT this file): +# config.add_autoload_paths_to_load_path = false + +### +# Remove the default X-Download-Options headers since it is used only by Internet Explorer. +# If you need to support Internet Explorer, add back `"X-Download-Options" => "noopen"`. +#++ +# Rails.application.config.action_dispatch.default_headers = { +# "X-Frame-Options" => "SAMEORIGIN", +# "X-XSS-Protection" => "0", +# "X-Content-Type-Options" => "nosniff", +# "X-Permitted-Cross-Domain-Policies" => "none", +# "Referrer-Policy" => "strict-origin-when-cross-origin" +# } + +### +# Do not treat an `ActionController::Parameters` instance +# as equal to an equivalent `Hash` by default. +#++ +# Rails.application.config.action_controller.allow_deprecated_parameters_hash_equality = false + +### +# Active Record Encryption now uses SHA-256 as its hash digest algorithm. +# +# There are 3 scenarios to consider. +# +# 1. If you have data encrypted with previous Rails versions, and you have +# +config.active_support.key_generator_hash_digest_class+ configured as SHA1 (the default +# before Rails 7.0), you need to configure SHA-1 for Active Record Encryption too: +#++ +# Rails.application.config.active_record.encryption.hash_digest_class = OpenSSL::Digest::SHA1 +# +# 2. If you have +config.active_support.key_generator_hash_digest_class+ configured as SHA256 (the new default +# in 7.0), then you need to configure SHA-256 for Active Record Encryption: +#++ +# Rails.application.config.active_record.encryption.hash_digest_class = OpenSSL::Digest::SHA256 +# +# 3. If you don't currently have data encrypted with Active Record encryption, you can disable this setting to +# configure the default behavior starting 7.1+: +#++ +# Rails.application.config.active_record.encryption.support_sha1_for_non_deterministic_encryption = false + +### +# No longer run after_commit callbacks on the first of multiple Active Record +# instances to save changes to the same database row within a transaction. +# Instead, run these callbacks on the instance most likely to have internal +# state which matches what was committed to the database, typically the last +# instance to save. +#++ +# Rails.application.config.active_record.run_commit_callbacks_on_first_saved_instances_in_transaction = false + +### +# Configures SQLite with a strict strings mode, which disables double-quoted string literals. +# +# SQLite has some quirks around double-quoted string literals. +# It first tries to consider double-quoted strings as identifier names, but if they don't exist +# it then considers them as string literals. Because of this, typos can silently go unnoticed. +# For example, it is possible to create an index for a non existing column. +# See https://www.sqlite.org/quirks.html#double_quoted_string_literals_are_accepted for more details. +#++ +# Rails.application.config.active_record.sqlite3_adapter_strict_strings_by_default = true + +### +# Disable deprecated singular associations names. +#++ +# Rails.application.config.active_record.allow_deprecated_singular_associations_name = false + +### +# Enable the Active Job `BigDecimal` argument serializer, which guarantees +# roundtripping. Without this serializer, some queue adapters may serialize +# `BigDecimal` arguments as simple (non-roundtrippable) strings. +# +# When deploying an application with multiple replicas, old (pre-Rails 7.1) +# replicas will not be able to deserialize `BigDecimal` arguments from this +# serializer. Therefore, this setting should only be enabled after all replicas +# have been successfully upgraded to Rails 7.1. +#++ +# Rails.application.config.active_job.use_big_decimal_serializer = true + +### +# Specify if an `ArgumentError` should be raised if `Rails.cache` `fetch` or +# `write` are given an invalid `expires_at` or `expires_in` time. +# Options are `true`, and `false`. If `false`, the exception will be reported +# as `handled` and logged instead. +#++ +# Rails.application.config.active_support.raise_on_invalid_cache_expiration_time = true + +### +# Specify whether Query Logs will format tags using the SQLCommenter format +# (https://open-telemetry.github.io/opentelemetry-sqlcommenter/), or using the legacy format. +# Options are `:legacy` and `:sqlcommenter`. +#++ +# Rails.application.config.active_record.query_log_tags_format = :sqlcommenter + +### +# Specify the default serializer used by `MessageEncryptor` and `MessageVerifier` +# instances. +# +# The legacy default is `:marshal`, which is a potential vector for +# deserialization attacks in cases where a message signing secret has been +# leaked. +# +# In Rails 7.1, the new default is `:json_allow_marshal` which serializes and +# deserializes with `ActiveSupport::JSON`, but can fall back to deserializing +# with `Marshal` so that legacy messages can still be read. +# +# In Rails 7.2, the default will become `:json` which serializes and +# deserializes with `ActiveSupport::JSON` only. +# +# Alternatively, you can choose `:message_pack` or `:message_pack_allow_marshal`, +# which serialize with `ActiveSupport::MessagePack`. `ActiveSupport::MessagePack` +# can roundtrip some Ruby types that are not supported by JSON, and may provide +# improved performance, but it requires the `msgpack` gem. +# +# For more information, see +# https://guides.rubyonrails.org/v7.1/configuring.html#config-active-support-message-serializer +# +# If you are performing a rolling deploy of a Rails 7.1 upgrade, wherein servers +# that have not yet been upgraded must be able to read messages from upgraded +# servers, first deploy without changing the serializer, then set the serializer +# in a subsequent deploy. +#++ +# Rails.application.config.active_support.message_serializer = :json_allow_marshal + +### +# Enable a performance optimization that serializes message data and metadata +# together. This changes the message format, so messages serialized this way +# cannot be read by older versions of Rails. However, messages that use the old +# format can still be read, regardless of whether this optimization is enabled. +# +# To perform a rolling deploy of a Rails 7.1 upgrade, wherein servers that have +# not yet been upgraded must be able to read messages from upgraded servers, +# leave this optimization off on the first deploy, then enable it on a +# subsequent deploy. +#++ +# Rails.application.config.active_support.use_message_serializer_for_metadata = true + +### +# Set the maximum size for Rails log files. +# +# `config.load_defaults 7.1` does not set this value for environments other than +# development and test. +#++ +# if Rails.env.local? +# Rails.application.config.log_file_size = 100 * 1024 * 1024 +# end + +### +# Enable raising on assignment to attr_readonly attributes. The previous +# behavior would allow assignment but silently not persist changes to the +# database. +#++ +# Rails.application.config.active_record.raise_on_assign_to_attr_readonly = true + +### +# Enable validating only parent-related columns for presence when the parent is mandatory. +# The previous behavior was to validate the presence of the parent record, which performed an extra query +# to get the parent every time the child record was updated, even when parent has not changed. +#++ +# Rails.application.config.active_record.belongs_to_required_validates_foreign_key = false + +### +# Enable precompilation of `config.filter_parameters`. Precompilation can +# improve filtering performance, depending on the quantity and types of filters. +#++ +# Rails.application.config.precompile_filter_parameters = true + +### +# Enable before_committed! callbacks on all enrolled records in a transaction. +# The previous behavior was to only run the callbacks on the first copy of a record +# if there were multiple copies of the same record enrolled in the transaction. +#++ +# Rails.application.config.active_record.before_committed_on_all_records = true + +### +# Disable automatic column serialization into YAML. +# To keep the historic behavior, you can set it to `YAML`, however it is +# recommended to explicitly define the serialization method for each column +# rather than to rely on a global default. +#++ +# Rails.application.config.active_record.default_column_serializer = nil + +### +# Enable a performance optimization that serializes Active Record models +# in a faster and more compact way. +# +# To perform a rolling deploy of a Rails 7.1 upgrade, wherein servers that have +# not yet been upgraded must be able to read caches from upgraded servers, +# leave this optimization off on the first deploy, then enable it on a +# subsequent deploy. +#++ +# Rails.application.config.active_record.marshalling_format_version = 7.1 + +### +# Run `after_commit` and `after_*_commit` callbacks in the order they are defined in a model. +# This matches the behaviour of all other callbacks. +# In previous versions of Rails, they ran in the inverse order. +#++ +# Rails.application.config.active_record.run_after_transaction_callbacks_in_order_defined = true + +### +# Whether a `transaction` block is committed or rolled back when exited via `return`, `break` or `throw`. +#++ +# Rails.application.config.active_record.commit_transaction_on_non_local_return = true + +### +# Controls when to generate a value for has_secure_token declarations. +#++ +# Rails.application.config.active_record.generate_secure_token_on = :initialize + +### +# ** Please read carefully, this must be configured in config/application.rb ** +# +# Change the format of the cache entry. +# +# Changing this default means that all new cache entries added to the cache +# will have a different format that is not supported by Rails 7.0 +# applications. +# +# Only change this value after your application is fully deployed to Rails 7.1 +# and you have no plans to rollback. +# When you're ready to change format, add this to `config/application.rb` (NOT +# this file): +# config.active_support.cache_format_version = 7.1 + +### +# Configure Action View to use HTML5 standards-compliant sanitizers when they are supported on your +# platform. +# +# `Rails::HTML::Sanitizer.best_supported_vendor` will cause Action View to use HTML5-compliant +# sanitizers if they are supported, else fall back to HTML4 sanitizers. +# +# In previous versions of Rails, Action View always used `Rails::HTML4::Sanitizer` as its vendor. +#++ +# Rails.application.config.action_view.sanitizer_vendor = Rails::HTML::Sanitizer.best_supported_vendor + +### +# Configure Action Text to use an HTML5 standards-compliant sanitizer when it is supported on your +# platform. +# +# `Rails::HTML::Sanitizer.best_supported_vendor` will cause Action Text to use HTML5-compliant +# sanitizers if they are supported, else fall back to HTML4 sanitizers. +# +# In previous versions of Rails, Action Text always used `Rails::HTML4::Sanitizer` as its vendor. +#++ +# Rails.application.config.action_text.sanitizer_vendor = Rails::HTML::Sanitizer.best_supported_vendor + +### +# Configure the log level used by the DebugExceptions middleware when logging +# uncaught exceptions during requests. +#++ +# Rails.application.config.action_dispatch.debug_exception_log_level = :error + +### +# Configure the test helpers in Action View, Action Dispatch, and rails-dom-testing to use HTML5 +# parsers. +# +# Nokogiri::HTML5 isn't supported on JRuby, so JRuby applications must set this to :html4. +# +# In previous versions of Rails, these test helpers always used an HTML4 parser. +#++ +# Rails.application.config.dom_testing_default_html_version = :html5 diff --git a/config/initializers/permissions_policy.rb b/config/initializers/permissions_policy.rb index 00f64d71..7db3b957 100644 --- a/config/initializers/permissions_policy.rb +++ b/config/initializers/permissions_policy.rb @@ -1,11 +1,13 @@ +# Be sure to restart your server when you modify this file. + # Define an application-wide HTTP permissions policy. For further -# information see https://developers.google.com/web/updates/2018/06/feature-policy -# -# Rails.application.config.permissions_policy do |f| -# f.camera :none -# f.gyroscope :none -# f.microphone :none -# f.usb :none -# f.fullscreen :self -# f.payment :self, "https://secure.example.com" +# information see: https://developers.google.com/web/updates/2018/06/feature-policy + +# Rails.application.config.permissions_policy do |policy| +# policy.camera :none +# policy.gyroscope :none +# policy.microphone :none +# policy.usb :none +# policy.fullscreen :self +# policy.payment :self, "https://secure.example.com" # end From e009561a4d38cae765b3a9c8500e0cf5ceff88c8 Mon Sep 17 00:00:00 2001 From: Fabio Lima Date: Sun, 15 Jun 2025 12:05:15 -0700 Subject: [PATCH 04/19] Refactor Postgres connection handling in Docker setup; use environment variables for host and port --- bin/docker/entrypoints/wait-for-postgres.sh | 7 +++++- config/database.yml | 2 +- docker-compose.ci.yml | 2 ++ docker-compose.yml | 28 +++++++++++---------- 4 files changed, 24 insertions(+), 15 deletions(-) diff --git a/bin/docker/entrypoints/wait-for-postgres.sh b/bin/docker/entrypoints/wait-for-postgres.sh index 26a40145..69c41d11 100755 --- a/bin/docker/entrypoints/wait-for-postgres.sh +++ b/bin/docker/entrypoints/wait-for-postgres.sh @@ -1,10 +1,15 @@ #!/bin/bash set -e +# Set default values if environment variables are not set +POSTGRES_HOST=${POSTGRES_HOST:-postgres} +POSTGRES_PORT=${POSTGRES_PORT:-5432} + # Wait for Postgres to start before doing anything echo "" echo "== ⏱ Waiting for Postgres before running: $@ ==" -dockerize -wait tcp://postgres:35432 -timeout 60s -wait-retry-interval 5s +echo "== 🔌 Connecting to ${POSTGRES_HOST}:${POSTGRES_PORT} ==" +dockerize -wait tcp://${POSTGRES_HOST}:${POSTGRES_PORT} -timeout 60s -wait-retry-interval 5s # Then exec the container's main process (what's set as CMD in the Dockerfile). echo "" diff --git a/config/database.yml b/config/database.yml index 8fa49950..931d9376 100644 --- a/config/database.yml +++ b/config/database.yml @@ -64,7 +64,7 @@ development: test: <<: *default # Uses linkvan-api/postgres container - url: postgres://postgres:postgres@localhost:5432 + # url: postgres://postgres:postgres@localhost:5432 database: linkvan_api_test # As with config/credentials.yml, you never want to store sensitive information, diff --git a/docker-compose.ci.yml b/docker-compose.ci.yml index 544912af..af68c1ae 100644 --- a/docker-compose.ci.yml +++ b/docker-compose.ci.yml @@ -17,6 +17,8 @@ x-ci-app: &ci-app RAILS_ENV: test RACK_ENV: test BUNDLE_PATH: /usr/src/app/vendor/bundle + POSTGRES_HOST: postgres + POSTGRES_PORT: 5432 entrypoint: ./bin/docker/entrypoints/wait-for-postgres.sh volumes: - .:/usr/src/app:cached diff --git a/docker-compose.yml b/docker-compose.yml index 6f819bec..daa126aa 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -20,6 +20,8 @@ x-app: &app # REDIS_URL: redis://@redis:6379/1 DATABASE_URL: postgres://postgres:postgres@postgres:35432/ GOOGLE_MAPS_API_TOKEN: ${GOOGLE_MAPS_API_TOKEN-} + POSTGRES_HOST: postgres + POSTGRES_PORT: 35432 entrypoint: ./bin/docker/entrypoints/wait-for-web.sh volumes: - .:/usr/src/app:cached @@ -32,7 +34,7 @@ x-app: &app - letter_opener:/usr/src/app/tmp/letter_opener:delegated depends_on: - postgres - # - redis +# - redis services: postgres: @@ -44,8 +46,8 @@ services: ports: - "35432" - "127.0.0.1:35432:35432" - # Uncomment to access this containers Postgres instance via port 5432 - # - "127.0.0.1:5432:5432" + # Uncomment to access this containers Postgres instance via port 5432 + # - "127.0.0.1:5432:5432" environment: PSQL_HISTFILE: /root/log/.psql_history POSTGRES_USER: postgres @@ -74,17 +76,17 @@ services: - "127.0.0.1:3000:3000" restart: on-failure - # worker: - # <<: *app - # command: bundle exec sidekiq -C config/sidekiq.yml +# worker: +# <<: *app +# command: bundle exec sidekiq -C config/sidekiq.yml - # webpacker: - # <<: *app - # command: yarn --build - # environment: - # WEBPACKER_DEV_SERVER_HOST: 0.0.0.0 - # ports: - # - "127.0.0.1:3035:3035" +# webpacker: +# <<: *app +# command: yarn --build +# environment: +# WEBPACKER_DEV_SERVER_HOST: 0.0.0.0 +# ports: +# - "127.0.0.1:3035:3035" volumes: postgresql: From 927fec051beeef77f6d447b88f7f115aff43a9b3 Mon Sep 17 00:00:00 2001 From: Fabio Lima Date: Sun, 15 Jun 2025 12:08:39 -0700 Subject: [PATCH 05/19] Enhance test script to conditionally run all tests or specific rspec tests based on arguments --- bin/docker/test | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/bin/docker/test b/bin/docker/test index 760bcdd1..261ec81c 100755 --- a/bin/docker/test +++ b/bin/docker/test @@ -1,4 +1,11 @@ #!/bin/bash set -e -docker-compose -f docker-compose.ci.yml run --rm test +# Pass all arguments to the rspec command inside docker +if [ $# -eq 0 ]; then + # No arguments provided, run all tests + docker-compose -f docker-compose.ci.yml run --rm test +else + # Arguments provided, pass them to rspec + docker-compose -f docker-compose.ci.yml run --rm test bash -c "./bin/setup && ./bin/rake assets:precompile && ./bin/bundle exec rspec $*" +fi From 3db3abe2c0f4287dc437d04c81a006728be7bf92 Mon Sep 17 00:00:00 2001 From: Fabio Lima Date: Sun, 15 Jun 2025 12:11:27 -0700 Subject: [PATCH 06/19] Remove version declaration from CI Docker Compose file --- docker-compose.ci.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/docker-compose.ci.yml b/docker-compose.ci.yml index af68c1ae..9310dde4 100644 --- a/docker-compose.ci.yml +++ b/docker-compose.ci.yml @@ -5,7 +5,6 @@ # # docker-compose -f docker-compose.ci.yml build test # docker-compose -f docker-compose.ci.yml run --rm test -version: '3' x-ci-app: &ci-app build: From a837fe7801de30a533f3738ecfca156cd8dfdd08 Mon Sep 17 00:00:00 2001 From: Fabio Lima Date: Sun, 15 Jun 2025 12:11:35 -0700 Subject: [PATCH 07/19] Add --remove-orphans flag to docker-compose test commands for improved cleanup --- bin/docker/test | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/docker/test b/bin/docker/test index 261ec81c..521b9f08 100755 --- a/bin/docker/test +++ b/bin/docker/test @@ -4,8 +4,8 @@ set -e # Pass all arguments to the rspec command inside docker if [ $# -eq 0 ]; then # No arguments provided, run all tests - docker-compose -f docker-compose.ci.yml run --rm test + docker-compose -f docker-compose.ci.yml run --rm --remove-orphans test else # Arguments provided, pass them to rspec - docker-compose -f docker-compose.ci.yml run --rm test bash -c "./bin/setup && ./bin/rake assets:precompile && ./bin/bundle exec rspec $*" + docker-compose -f docker-compose.ci.yml run --rm --remove-orphans test bash -c "./bin/setup && ./bin/rake assets:precompile && ./bin/bundle exec rspec $*" fi From 788262332743d55508cc8cb68e3219e9bf7faac2 Mon Sep 17 00:00:00 2001 From: Fabio Lima Date: Sun, 15 Jun 2025 12:19:20 -0700 Subject: [PATCH 08/19] Update docker commands to include project name for consistency across scripts --- bin/docker/bash | 2 +- bin/docker/bundle | 2 +- bin/docker/dev_reset | 2 +- bin/docker/run | 2 +- bin/docker/setup | 6 +++--- bin/docker/start | 2 +- bin/docker/test | 4 ++-- bin/docker/yarn | 2 +- 8 files changed, 11 insertions(+), 11 deletions(-) diff --git a/bin/docker/bash b/bin/docker/bash index 0593c5ab..98a6840f 100755 --- a/bin/docker/bash +++ b/bin/docker/bash @@ -1,4 +1,4 @@ #!/bin/bash set -e -docker-compose run --rm web bash +docker-compose -p linkvan-dev run --rm web bash diff --git a/bin/docker/bundle b/bin/docker/bundle index eef0d244..a82c846d 100755 --- a/bin/docker/bundle +++ b/bin/docker/bundle @@ -1,4 +1,4 @@ #!/bin/bash set -e -exec docker-compose --rm web bundle "$@" +exec docker-compose -p linkvan-dev run --rm web bundle "$@" diff --git a/bin/docker/dev_reset b/bin/docker/dev_reset index ebb462d1..f98ffb0f 100755 --- a/bin/docker/dev_reset +++ b/bin/docker/dev_reset @@ -9,7 +9,7 @@ def system!(*args) end def docked!(*args) - system!("docker-compose run -rm web", *args) + system!("docker-compose -p linkvan-dev run -rm web", *args) end FileUtils.chdir APP_ROOT do diff --git a/bin/docker/run b/bin/docker/run index 76bd8813..4c76fe80 100755 --- a/bin/docker/run +++ b/bin/docker/run @@ -2,4 +2,4 @@ # Little helper to run a command from the docker container set -e -exec docker-compose run --rm web "$@" +exec docker-compose -p linkvan-dev run --rm web "$@" diff --git a/bin/docker/setup b/bin/docker/setup index f04f7ae0..60607fd1 100755 --- a/bin/docker/setup +++ b/bin/docker/setup @@ -9,7 +9,7 @@ def system!(*args) end def docked!(*args) - command_line = ["docker-compose run --rm web"] + args + command_line = ["docker-compose -p linkvan-dev run --rm web"] + args system!(command_line.join(" ")) end @@ -19,10 +19,10 @@ FileUtils.chdir APP_ROOT do FileUtils.cp ".env.template", ".env" unless File.exist?(".env") puts "== Pulling Images ==" - system! "docker-compose pull" + system! "docker-compose -p linkvan-dev pull" puts "== Building Container ==" - system! "docker-compose build" + system! "docker-compose -p linkvan-dev build" puts "== Running: bin/setup #{ARGV.join(' ')} ==" docked!("./bin/setup", ARGV) diff --git a/bin/docker/start b/bin/docker/start index 746c7468..764854ac 100755 --- a/bin/docker/start +++ b/bin/docker/start @@ -2,4 +2,4 @@ set -e echo "== Turning on Docker ==" -docker-compose up +docker-compose -p linkvan-dev up diff --git a/bin/docker/test b/bin/docker/test index 521b9f08..f61e6de7 100755 --- a/bin/docker/test +++ b/bin/docker/test @@ -4,8 +4,8 @@ set -e # Pass all arguments to the rspec command inside docker if [ $# -eq 0 ]; then # No arguments provided, run all tests - docker-compose -f docker-compose.ci.yml run --rm --remove-orphans test + docker-compose -f docker-compose.ci.yml -p linkvan-test run --rm test else # Arguments provided, pass them to rspec - docker-compose -f docker-compose.ci.yml run --rm --remove-orphans test bash -c "./bin/setup && ./bin/rake assets:precompile && ./bin/bundle exec rspec $*" + docker-compose -f docker-compose.ci.yml -p linkvan-test run --rm test bash -c "./bin/setup && ./bin/rake assets:precompile && ./bin/bundle exec rspec $*" fi diff --git a/bin/docker/yarn b/bin/docker/yarn index 8ae101d2..dbc9b1c0 100755 --- a/bin/docker/yarn +++ b/bin/docker/yarn @@ -1,4 +1,4 @@ #!/bin/bash set -e -exec docker-compose --rm web yarn "$@" +exec docker-compose -p linkvan-dev run --rm web yarn "$@" From d296f8d98c11aa7db7210cd9f19e73a81c6b2cf3 Mon Sep 17 00:00:00 2001 From: Fabio Lima Date: Sun, 15 Jun 2025 12:35:12 -0700 Subject: [PATCH 09/19] Refactor setup script to improve error handling and formatting consistency --- bin/setup | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/bin/setup b/bin/setup index 32257efc..ba48a686 100755 --- a/bin/setup +++ b/bin/setup @@ -10,7 +10,7 @@ restart = ARGV.include?('restart') APP_ROOT = File.expand_path("..", __dir__) def system!(*args) - system(*args) || abort("\n== Command #{args} failed ==") + system(*args, exception: true) end FileUtils.chdir APP_ROOT do @@ -33,8 +33,8 @@ FileUtils.chdir APP_ROOT do system! "bin/rails db:reset" else # Creates db, loads schema, initializes seed data. - puts "\n== Preparing database ==" - system! "bin/rails db:prepare" + puts "\n== Preparing database ==" + system! "bin/rails db:prepare" end if load_fake_data @@ -46,7 +46,7 @@ FileUtils.chdir APP_ROOT do system! "bin/rails log:clear tmp:clear" if restart - puts "\n== Restarting application server ==" - system! "bin/rails restart" + puts "\n== Restarting application server ==" + system! "bin/rails restart" end end From 531a5099dc4af4592bb392aa1457b8aaab97d02e Mon Sep 17 00:00:00 2001 From: Fabio Lima Date: Sun, 15 Jun 2025 12:42:00 -0700 Subject: [PATCH 10/19] Fix facilities fake data generation --- lib/tasks/fake_data/facilities.rake | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/tasks/fake_data/facilities.rake b/lib/tasks/fake_data/facilities.rake index 82b2d4f0..6f9cdc9f 100644 --- a/lib/tasks/fake_data/facilities.rake +++ b/lib/tasks/fake_data/facilities.rake @@ -29,7 +29,6 @@ namespace :fake_data do params[:long] = rand(*LIMITS[:long]) params[:phone] = Faker::PhoneNumber.cell_phone params[:website] = Faker::Internet.url(path: "") - params[:description] = Faker::Lorem.paragraph params[:notes] = Faker::Lorem.paragraphs.join("\n\n") params[:verified] = (rand > 0.4) params[:zone] = zones.sample From 7bee8eeaae8e24886358c50caa2e86b7e67be339 Mon Sep 17 00:00:00 2001 From: Fabio Lima Date: Sun, 15 Jun 2025 12:54:28 -0700 Subject: [PATCH 11/19] Update application configuration to disable autoloaded paths in load path and set default headers --- config/application.rb | 7 +++++ .../new_framework_defaults_7_1.rb | 26 ++++++------------- 2 files changed, 15 insertions(+), 18 deletions(-) diff --git a/config/application.rb b/config/application.rb index 99534a23..0f6d8084 100644 --- a/config/application.rb +++ b/config/application.rb @@ -11,6 +11,13 @@ class Application < Rails::Application # Initialize configuration defaults for originally generated Rails version. config.load_defaults 7.0 + # No longer add autoloaded paths into `$LOAD_PATH`. This means that you won't be able + # to manually require files that are managed by the autoloader, which you shouldn't do anyway. + # + # This will reduce the size of the load path, making `require` faster if you don't use bootsnap, or reduce the size + # of the bootsnap cache if you use it. + config.add_autoload_paths_to_load_path = false + # 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. diff --git a/config/initializers/new_framework_defaults_7_1.rb b/config/initializers/new_framework_defaults_7_1.rb index 3dc295db..fd057971 100644 --- a/config/initializers/new_framework_defaults_7_1.rb +++ b/config/initializers/new_framework_defaults_7_1.rb @@ -9,33 +9,23 @@ # Read the Guide for Upgrading Ruby on Rails for more info on each option. # https://guides.rubyonrails.org/upgrading_ruby_on_rails.html -### -# No longer add autoloaded paths into `$LOAD_PATH`. This means that you won't be able -# to manually require files that are managed by the autoloader, which you shouldn't do anyway. -# -# This will reduce the size of the load path, making `require` faster if you don't use bootsnap, or reduce the size -# of the bootsnap cache if you use it. -# -# To set this configuration, add the following line to `config/application.rb` (NOT this file): -# config.add_autoload_paths_to_load_path = false - ### # Remove the default X-Download-Options headers since it is used only by Internet Explorer. # If you need to support Internet Explorer, add back `"X-Download-Options" => "noopen"`. #++ -# Rails.application.config.action_dispatch.default_headers = { -# "X-Frame-Options" => "SAMEORIGIN", -# "X-XSS-Protection" => "0", -# "X-Content-Type-Options" => "nosniff", -# "X-Permitted-Cross-Domain-Policies" => "none", -# "Referrer-Policy" => "strict-origin-when-cross-origin" -# } +Rails.application.config.action_dispatch.default_headers = { + "X-Frame-Options" => "SAMEORIGIN", + "X-XSS-Protection" => "0", + "X-Content-Type-Options" => "nosniff", + "X-Permitted-Cross-Domain-Policies" => "none", + "Referrer-Policy" => "strict-origin-when-cross-origin" +} ### # Do not treat an `ActionController::Parameters` instance # as equal to an equivalent `Hash` by default. #++ -# Rails.application.config.action_controller.allow_deprecated_parameters_hash_equality = false +Rails.application.config.action_controller.allow_deprecated_parameters_hash_equality = false ### # Active Record Encryption now uses SHA-256 as its hash digest algorithm. From e82d4f40cfe939afcadcd9e5d0bb1587a088cf4d Mon Sep 17 00:00:00 2001 From: Fabio Lima Date: Sat, 28 Jun 2025 14:57:08 -0700 Subject: [PATCH 12/19] Fix migrations (#219) * Add local port mapping for Postgres and enhance logging in data rake task * Fix facility suitability migration --- ...61125211440_change_facility_suitability.rb | 19 +++++++------------ docker-compose.yml | 1 + lib/tasks/data.rake | 3 +++ 3 files changed, 11 insertions(+), 12 deletions(-) diff --git a/db/migrate/20161125211440_change_facility_suitability.rb b/db/migrate/20161125211440_change_facility_suitability.rb index e7db6873..5f10e19d 100644 --- a/db/migrate/20161125211440_change_facility_suitability.rb +++ b/db/migrate/20161125211440_change_facility_suitability.rb @@ -1,21 +1,16 @@ class ChangeFacilitySuitability < ActiveRecord::Migration[4.2] + # Define a local model class that only knows about existing columns + class MigrationFacility < ActiveRecord::Base + self.table_name = 'facilities' + end + def up change_column :facilities, :suitability, :string - Facility.find_each do |f| - if f.suitability == "Children" - f.suitability = "children" - f.save - end - end + MigrationFacility.where(suitability: "Children").update_all(suitability: "children") end def down change_column :facilities, :suitability, :string - Facility.find_each do |f| - if f.suitability == "children" - f.suitability = "Children" - f.save - end - end + MigrationFacility.where(suitability: "children").update_all(suitability: "Children") end end diff --git a/docker-compose.yml b/docker-compose.yml index 26e712c3..d1c48363 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -44,6 +44,7 @@ services: - "35432" ports: - "35432" + - "127.0.0.1:35432:35432" # Uncomment to access this containers Postgres instance via port 5432 # - "127.0.0.1:5432:5432" environment: diff --git a/lib/tasks/data.rake b/lib/tasks/data.rake index 145edaeb..d899223c 100644 --- a/lib/tasks/data.rake +++ b/lib/tasks/data.rake @@ -28,6 +28,7 @@ namespace :data do "#{header} #{msg}\n" end + attention_logger = ActiveSupport::Logger.new("#{Rails.root}/log/import.log") logger = Rails.logger logger.extend(ActiveSupport::Logger.broadcast(stdout_logger)) @@ -135,6 +136,7 @@ namespace :data do next if time_slot.save logger.warn "[seed_fake] Can't create #{idx + 1}#{(idx + 1).ordinal} time slot for facility (id: #{facility.id}). Errors: #{time_slot.errors.full_messages}" + attention_logger.warn "[import] Can't create #{idx + 1}#{(idx + 1).ordinal} time slot for facility '#{facility.name}' (id: #{facility.id}). Errors: #{time_slot.errors.full_messages}" failed_schedules << facility.id end end @@ -168,6 +170,7 @@ namespace :data do ApplicationRecord.transaction do unless facility.save logger.error "[seed_fake] Failed to create Facility (id: #{facility_attribs["id"]}). Errors: #{facility.errors.full_messages}" + attention_logger.error "[import] Failed to create Facility '#{facility.name}' (id: #{facility_attribs["id"]}). Errors: #{facility.errors.full_messages}" next end From 4ffe866a17c17d9766f403a3302dbf78ac2026da Mon Sep 17 00:00:00 2001 From: Fabio Lima Date: Sat, 28 Jun 2025 19:00:47 -0700 Subject: [PATCH 13/19] Fix migration to use MigrationFacility class for updating welcomes --- db/migrate/20170311000347_add_suitability_to_welcomes.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/db/migrate/20170311000347_add_suitability_to_welcomes.rb b/db/migrate/20170311000347_add_suitability_to_welcomes.rb index e8a66c1c..705845bb 100644 --- a/db/migrate/20170311000347_add_suitability_to_welcomes.rb +++ b/db/migrate/20170311000347_add_suitability_to_welcomes.rb @@ -1,7 +1,11 @@ class AddSuitabilityToWelcomes < ActiveRecord::Migration[4.2] + class MigrationFacility < ActiveRecord::Base + self.table_name = 'facilities' + end + def change change_column :facilities, :welcomes, :string - Facility.find_each do |f| + MigrationFacility.find_each do |f| f.welcomes = f.welcomes.concat(" " + f.suitability) f.save end From 7527626954290fe67641c73d94981c312dc84dda Mon Sep 17 00:00:00 2001 From: Fabio Lima Date: Sat, 28 Jun 2025 19:05:52 -0700 Subject: [PATCH 14/19] Fix migration to use MigrationFacility class for updating zone references --- db/migrate/20190824231340_add_zone_to_facilities.rb | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/db/migrate/20190824231340_add_zone_to_facilities.rb b/db/migrate/20190824231340_add_zone_to_facilities.rb index 48100eb7..fa66969e 100644 --- a/db/migrate/20190824231340_add_zone_to_facilities.rb +++ b/db/migrate/20190824231340_add_zone_to_facilities.rb @@ -1,4 +1,8 @@ class AddZoneToFacilities < ActiveRecord::Migration[4.2] + class MigrationFacility < ActiveRecord::Base + self.table_name = 'facilities' + end + def change add_reference :facilities, :zone, index: true, foreign_key: true @@ -9,11 +13,11 @@ def change reversible do |dir| dir.up do zone = Zone.create(name: zone_name, description: zone_description) - Facility.update_all({ zone_id: zone.id }) + MigrationFacility.update_all({ zone_id: zone.id }) end dir.down do - Facility.update_all({ zone_id: nil }) + MigrationFacility.update_all({ zone_id: nil }) zone = Zone.find_by(name: zone_name) zone.destroy end From f8bd94a3926023e02485bc21fcf0ea291244c791 Mon Sep 17 00:00:00 2001 From: Fabio Lima Date: Sat, 28 Jun 2025 19:13:47 -0700 Subject: [PATCH 15/19] Fix migration to use MigrationFacility class for importing facility schedules --- ...0523173050_import_facilities_schedule_from_facilities.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/db/migrate/20210523173050_import_facilities_schedule_from_facilities.rb b/db/migrate/20210523173050_import_facilities_schedule_from_facilities.rb index 6174a5e0..64e474e8 100644 --- a/db/migrate/20210523173050_import_facilities_schedule_from_facilities.rb +++ b/db/migrate/20210523173050_import_facilities_schedule_from_facilities.rb @@ -7,8 +7,12 @@ class ImportFacilitiesScheduleFromFacilities < ActiveRecord::Migration[6.1] fri: :friday, sat: :saturday }.freeze + class MigrationFacility < ActiveRecord::Base + self.table_name = 'facilities' + end + def up - Facility.all.find_each do |facility| + MigrationFacility.all.find_each do |facility| say_with_time "Facility: #{facility.id}" do create_schedules(facility) end From 69e2dbf051e3e7513a206c7f26b05c4d813aa5b6 Mon Sep 17 00:00:00 2001 From: Fabio Lima Date: Sun, 14 Sep 2025 09:28:49 -0700 Subject: [PATCH 16/19] Finish going through each new_framework_defaults initializer --- config/application.rb | 3 + .../new_framework_defaults_7_1.rb | 63 +++++++------------ 2 files changed, 26 insertions(+), 40 deletions(-) diff --git a/config/application.rb b/config/application.rb index 0f6d8084..d59b5237 100644 --- a/config/application.rb +++ b/config/application.rb @@ -11,6 +11,9 @@ class Application < Rails::Application # Initialize configuration defaults for originally generated Rails version. config.load_defaults 7.0 + # cache entry format version + config.active_support.cache_format_version = 7.1 + # No longer add autoloaded paths into `$LOAD_PATH`. This means that you won't be able # to manually require files that are managed by the autoloader, which you shouldn't do anyway. # diff --git a/config/initializers/new_framework_defaults_7_1.rb b/config/initializers/new_framework_defaults_7_1.rb index fd057971..a3a7d1b1 100644 --- a/config/initializers/new_framework_defaults_7_1.rb +++ b/config/initializers/new_framework_defaults_7_1.rb @@ -46,7 +46,7 @@ # 3. If you don't currently have data encrypted with Active Record encryption, you can disable this setting to # configure the default behavior starting 7.1+: #++ -# Rails.application.config.active_record.encryption.support_sha1_for_non_deterministic_encryption = false +Rails.application.config.active_record.encryption.support_sha1_for_non_deterministic_encryption = false ### # No longer run after_commit callbacks on the first of multiple Active Record @@ -55,7 +55,7 @@ # state which matches what was committed to the database, typically the last # instance to save. #++ -# Rails.application.config.active_record.run_commit_callbacks_on_first_saved_instances_in_transaction = false +Rails.application.config.active_record.run_commit_callbacks_on_first_saved_instances_in_transaction = false ### # Configures SQLite with a strict strings mode, which disables double-quoted string literals. @@ -66,12 +66,12 @@ # For example, it is possible to create an index for a non existing column. # See https://www.sqlite.org/quirks.html#double_quoted_string_literals_are_accepted for more details. #++ -# Rails.application.config.active_record.sqlite3_adapter_strict_strings_by_default = true +Rails.application.config.active_record.sqlite3_adapter_strict_strings_by_default = true ### # Disable deprecated singular associations names. #++ -# Rails.application.config.active_record.allow_deprecated_singular_associations_name = false +Rails.application.config.active_record.allow_deprecated_singular_associations_name = false ### # Enable the Active Job `BigDecimal` argument serializer, which guarantees @@ -83,7 +83,7 @@ # serializer. Therefore, this setting should only be enabled after all replicas # have been successfully upgraded to Rails 7.1. #++ -# Rails.application.config.active_job.use_big_decimal_serializer = true +Rails.application.config.active_job.use_big_decimal_serializer = true ### # Specify if an `ArgumentError` should be raised if `Rails.cache` `fetch` or @@ -91,14 +91,14 @@ # Options are `true`, and `false`. If `false`, the exception will be reported # as `handled` and logged instead. #++ -# Rails.application.config.active_support.raise_on_invalid_cache_expiration_time = true +Rails.application.config.active_support.raise_on_invalid_cache_expiration_time = true ### # Specify whether Query Logs will format tags using the SQLCommenter format # (https://open-telemetry.github.io/opentelemetry-sqlcommenter/), or using the legacy format. # Options are `:legacy` and `:sqlcommenter`. #++ -# Rails.application.config.active_record.query_log_tags_format = :sqlcommenter +Rails.application.config.active_record.query_log_tags_format = :sqlcommenter ### # Specify the default serializer used by `MessageEncryptor` and `MessageVerifier` @@ -128,7 +128,7 @@ # servers, first deploy without changing the serializer, then set the serializer # in a subsequent deploy. #++ -# Rails.application.config.active_support.message_serializer = :json_allow_marshal +Rails.application.config.active_support.message_serializer = :json_allow_marshal ### # Enable a performance optimization that serializes message data and metadata @@ -141,7 +141,7 @@ # leave this optimization off on the first deploy, then enable it on a # subsequent deploy. #++ -# Rails.application.config.active_support.use_message_serializer_for_metadata = true +Rails.application.config.active_support.use_message_serializer_for_metadata = true ### # Set the maximum size for Rails log files. @@ -149,36 +149,34 @@ # `config.load_defaults 7.1` does not set this value for environments other than # development and test. #++ -# if Rails.env.local? -# Rails.application.config.log_file_size = 100 * 1024 * 1024 -# end +Rails.application.config.log_file_size = 100 * 1024 * 1024 if Rails.env.local? ### # Enable raising on assignment to attr_readonly attributes. The previous # behavior would allow assignment but silently not persist changes to the # database. #++ -# Rails.application.config.active_record.raise_on_assign_to_attr_readonly = true +Rails.application.config.active_record.raise_on_assign_to_attr_readonly = true ### # Enable validating only parent-related columns for presence when the parent is mandatory. # The previous behavior was to validate the presence of the parent record, which performed an extra query # to get the parent every time the child record was updated, even when parent has not changed. #++ -# Rails.application.config.active_record.belongs_to_required_validates_foreign_key = false +Rails.application.config.active_record.belongs_to_required_validates_foreign_key = false ### # Enable precompilation of `config.filter_parameters`. Precompilation can # improve filtering performance, depending on the quantity and types of filters. #++ -# Rails.application.config.precompile_filter_parameters = true +Rails.application.config.precompile_filter_parameters = true ### # Enable before_committed! callbacks on all enrolled records in a transaction. # The previous behavior was to only run the callbacks on the first copy of a record # if there were multiple copies of the same record enrolled in the transaction. #++ -# Rails.application.config.active_record.before_committed_on_all_records = true +Rails.application.config.active_record.before_committed_on_all_records = true ### # Disable automatic column serialization into YAML. @@ -186,7 +184,7 @@ # recommended to explicitly define the serialization method for each column # rather than to rely on a global default. #++ -# Rails.application.config.active_record.default_column_serializer = nil +Rails.application.config.active_record.default_column_serializer = nil ### # Enable a performance optimization that serializes Active Record models @@ -197,39 +195,24 @@ # leave this optimization off on the first deploy, then enable it on a # subsequent deploy. #++ -# Rails.application.config.active_record.marshalling_format_version = 7.1 +Rails.application.config.active_record.marshalling_format_version = 7.1 ### # Run `after_commit` and `after_*_commit` callbacks in the order they are defined in a model. # This matches the behaviour of all other callbacks. # In previous versions of Rails, they ran in the inverse order. #++ -# Rails.application.config.active_record.run_after_transaction_callbacks_in_order_defined = true +Rails.application.config.active_record.run_after_transaction_callbacks_in_order_defined = true ### # Whether a `transaction` block is committed or rolled back when exited via `return`, `break` or `throw`. #++ -# Rails.application.config.active_record.commit_transaction_on_non_local_return = true +Rails.application.config.active_record.commit_transaction_on_non_local_return = true ### # Controls when to generate a value for has_secure_token declarations. #++ -# Rails.application.config.active_record.generate_secure_token_on = :initialize - -### -# ** Please read carefully, this must be configured in config/application.rb ** -# -# Change the format of the cache entry. -# -# Changing this default means that all new cache entries added to the cache -# will have a different format that is not supported by Rails 7.0 -# applications. -# -# Only change this value after your application is fully deployed to Rails 7.1 -# and you have no plans to rollback. -# When you're ready to change format, add this to `config/application.rb` (NOT -# this file): -# config.active_support.cache_format_version = 7.1 +Rails.application.config.active_record.generate_secure_token_on = :initialize ### # Configure Action View to use HTML5 standards-compliant sanitizers when they are supported on your @@ -240,7 +223,7 @@ # # In previous versions of Rails, Action View always used `Rails::HTML4::Sanitizer` as its vendor. #++ -# Rails.application.config.action_view.sanitizer_vendor = Rails::HTML::Sanitizer.best_supported_vendor +Rails.application.config.action_view.sanitizer_vendor = Rails::HTML::Sanitizer.best_supported_vendor ### # Configure Action Text to use an HTML5 standards-compliant sanitizer when it is supported on your @@ -251,13 +234,13 @@ # # In previous versions of Rails, Action Text always used `Rails::HTML4::Sanitizer` as its vendor. #++ -# Rails.application.config.action_text.sanitizer_vendor = Rails::HTML::Sanitizer.best_supported_vendor +Rails.application.config.action_text.sanitizer_vendor = Rails::HTML::Sanitizer.best_supported_vendor ### # Configure the log level used by the DebugExceptions middleware when logging # uncaught exceptions during requests. #++ -# Rails.application.config.action_dispatch.debug_exception_log_level = :error +Rails.application.config.action_dispatch.debug_exception_log_level = :error ### # Configure the test helpers in Action View, Action Dispatch, and rails-dom-testing to use HTML5 @@ -267,4 +250,4 @@ # # In previous versions of Rails, these test helpers always used an HTML4 parser. #++ -# Rails.application.config.dom_testing_default_html_version = :html5 +Rails.application.config.dom_testing_default_html_version = :html5 From 5a57d5c474144a594b4425bb1e55937aab750e18 Mon Sep 17 00:00:00 2001 From: Fabio Lima Date: Sun, 14 Sep 2025 09:33:00 -0700 Subject: [PATCH 17/19] Finish upgrading to Rails 7.1 --- config/application.rb | 2 +- .../new_framework_defaults_7_1.rb | 253 ------------------ 2 files changed, 1 insertion(+), 254 deletions(-) delete mode 100644 config/initializers/new_framework_defaults_7_1.rb diff --git a/config/application.rb b/config/application.rb index d59b5237..e7b3d541 100644 --- a/config/application.rb +++ b/config/application.rb @@ -9,7 +9,7 @@ module LinkvanApi class Application < Rails::Application # Initialize configuration defaults for originally generated Rails version. - config.load_defaults 7.0 + config.load_defaults 7.1 # cache entry format version config.active_support.cache_format_version = 7.1 diff --git a/config/initializers/new_framework_defaults_7_1.rb b/config/initializers/new_framework_defaults_7_1.rb deleted file mode 100644 index a3a7d1b1..00000000 --- a/config/initializers/new_framework_defaults_7_1.rb +++ /dev/null @@ -1,253 +0,0 @@ -# Be sure to restart your server when you modify this file. -# -# This file eases your Rails 7.1 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.1`. -# -# Read the Guide for Upgrading Ruby on Rails for more info on each option. -# https://guides.rubyonrails.org/upgrading_ruby_on_rails.html - -### -# Remove the default X-Download-Options headers since it is used only by Internet Explorer. -# If you need to support Internet Explorer, add back `"X-Download-Options" => "noopen"`. -#++ -Rails.application.config.action_dispatch.default_headers = { - "X-Frame-Options" => "SAMEORIGIN", - "X-XSS-Protection" => "0", - "X-Content-Type-Options" => "nosniff", - "X-Permitted-Cross-Domain-Policies" => "none", - "Referrer-Policy" => "strict-origin-when-cross-origin" -} - -### -# Do not treat an `ActionController::Parameters` instance -# as equal to an equivalent `Hash` by default. -#++ -Rails.application.config.action_controller.allow_deprecated_parameters_hash_equality = false - -### -# Active Record Encryption now uses SHA-256 as its hash digest algorithm. -# -# There are 3 scenarios to consider. -# -# 1. If you have data encrypted with previous Rails versions, and you have -# +config.active_support.key_generator_hash_digest_class+ configured as SHA1 (the default -# before Rails 7.0), you need to configure SHA-1 for Active Record Encryption too: -#++ -# Rails.application.config.active_record.encryption.hash_digest_class = OpenSSL::Digest::SHA1 -# -# 2. If you have +config.active_support.key_generator_hash_digest_class+ configured as SHA256 (the new default -# in 7.0), then you need to configure SHA-256 for Active Record Encryption: -#++ -# Rails.application.config.active_record.encryption.hash_digest_class = OpenSSL::Digest::SHA256 -# -# 3. If you don't currently have data encrypted with Active Record encryption, you can disable this setting to -# configure the default behavior starting 7.1+: -#++ -Rails.application.config.active_record.encryption.support_sha1_for_non_deterministic_encryption = false - -### -# No longer run after_commit callbacks on the first of multiple Active Record -# instances to save changes to the same database row within a transaction. -# Instead, run these callbacks on the instance most likely to have internal -# state which matches what was committed to the database, typically the last -# instance to save. -#++ -Rails.application.config.active_record.run_commit_callbacks_on_first_saved_instances_in_transaction = false - -### -# Configures SQLite with a strict strings mode, which disables double-quoted string literals. -# -# SQLite has some quirks around double-quoted string literals. -# It first tries to consider double-quoted strings as identifier names, but if they don't exist -# it then considers them as string literals. Because of this, typos can silently go unnoticed. -# For example, it is possible to create an index for a non existing column. -# See https://www.sqlite.org/quirks.html#double_quoted_string_literals_are_accepted for more details. -#++ -Rails.application.config.active_record.sqlite3_adapter_strict_strings_by_default = true - -### -# Disable deprecated singular associations names. -#++ -Rails.application.config.active_record.allow_deprecated_singular_associations_name = false - -### -# Enable the Active Job `BigDecimal` argument serializer, which guarantees -# roundtripping. Without this serializer, some queue adapters may serialize -# `BigDecimal` arguments as simple (non-roundtrippable) strings. -# -# When deploying an application with multiple replicas, old (pre-Rails 7.1) -# replicas will not be able to deserialize `BigDecimal` arguments from this -# serializer. Therefore, this setting should only be enabled after all replicas -# have been successfully upgraded to Rails 7.1. -#++ -Rails.application.config.active_job.use_big_decimal_serializer = true - -### -# Specify if an `ArgumentError` should be raised if `Rails.cache` `fetch` or -# `write` are given an invalid `expires_at` or `expires_in` time. -# Options are `true`, and `false`. If `false`, the exception will be reported -# as `handled` and logged instead. -#++ -Rails.application.config.active_support.raise_on_invalid_cache_expiration_time = true - -### -# Specify whether Query Logs will format tags using the SQLCommenter format -# (https://open-telemetry.github.io/opentelemetry-sqlcommenter/), or using the legacy format. -# Options are `:legacy` and `:sqlcommenter`. -#++ -Rails.application.config.active_record.query_log_tags_format = :sqlcommenter - -### -# Specify the default serializer used by `MessageEncryptor` and `MessageVerifier` -# instances. -# -# The legacy default is `:marshal`, which is a potential vector for -# deserialization attacks in cases where a message signing secret has been -# leaked. -# -# In Rails 7.1, the new default is `:json_allow_marshal` which serializes and -# deserializes with `ActiveSupport::JSON`, but can fall back to deserializing -# with `Marshal` so that legacy messages can still be read. -# -# In Rails 7.2, the default will become `:json` which serializes and -# deserializes with `ActiveSupport::JSON` only. -# -# Alternatively, you can choose `:message_pack` or `:message_pack_allow_marshal`, -# which serialize with `ActiveSupport::MessagePack`. `ActiveSupport::MessagePack` -# can roundtrip some Ruby types that are not supported by JSON, and may provide -# improved performance, but it requires the `msgpack` gem. -# -# For more information, see -# https://guides.rubyonrails.org/v7.1/configuring.html#config-active-support-message-serializer -# -# If you are performing a rolling deploy of a Rails 7.1 upgrade, wherein servers -# that have not yet been upgraded must be able to read messages from upgraded -# servers, first deploy without changing the serializer, then set the serializer -# in a subsequent deploy. -#++ -Rails.application.config.active_support.message_serializer = :json_allow_marshal - -### -# Enable a performance optimization that serializes message data and metadata -# together. This changes the message format, so messages serialized this way -# cannot be read by older versions of Rails. However, messages that use the old -# format can still be read, regardless of whether this optimization is enabled. -# -# To perform a rolling deploy of a Rails 7.1 upgrade, wherein servers that have -# not yet been upgraded must be able to read messages from upgraded servers, -# leave this optimization off on the first deploy, then enable it on a -# subsequent deploy. -#++ -Rails.application.config.active_support.use_message_serializer_for_metadata = true - -### -# Set the maximum size for Rails log files. -# -# `config.load_defaults 7.1` does not set this value for environments other than -# development and test. -#++ -Rails.application.config.log_file_size = 100 * 1024 * 1024 if Rails.env.local? - -### -# Enable raising on assignment to attr_readonly attributes. The previous -# behavior would allow assignment but silently not persist changes to the -# database. -#++ -Rails.application.config.active_record.raise_on_assign_to_attr_readonly = true - -### -# Enable validating only parent-related columns for presence when the parent is mandatory. -# The previous behavior was to validate the presence of the parent record, which performed an extra query -# to get the parent every time the child record was updated, even when parent has not changed. -#++ -Rails.application.config.active_record.belongs_to_required_validates_foreign_key = false - -### -# Enable precompilation of `config.filter_parameters`. Precompilation can -# improve filtering performance, depending on the quantity and types of filters. -#++ -Rails.application.config.precompile_filter_parameters = true - -### -# Enable before_committed! callbacks on all enrolled records in a transaction. -# The previous behavior was to only run the callbacks on the first copy of a record -# if there were multiple copies of the same record enrolled in the transaction. -#++ -Rails.application.config.active_record.before_committed_on_all_records = true - -### -# Disable automatic column serialization into YAML. -# To keep the historic behavior, you can set it to `YAML`, however it is -# recommended to explicitly define the serialization method for each column -# rather than to rely on a global default. -#++ -Rails.application.config.active_record.default_column_serializer = nil - -### -# Enable a performance optimization that serializes Active Record models -# in a faster and more compact way. -# -# To perform a rolling deploy of a Rails 7.1 upgrade, wherein servers that have -# not yet been upgraded must be able to read caches from upgraded servers, -# leave this optimization off on the first deploy, then enable it on a -# subsequent deploy. -#++ -Rails.application.config.active_record.marshalling_format_version = 7.1 - -### -# Run `after_commit` and `after_*_commit` callbacks in the order they are defined in a model. -# This matches the behaviour of all other callbacks. -# In previous versions of Rails, they ran in the inverse order. -#++ -Rails.application.config.active_record.run_after_transaction_callbacks_in_order_defined = true - -### -# Whether a `transaction` block is committed or rolled back when exited via `return`, `break` or `throw`. -#++ -Rails.application.config.active_record.commit_transaction_on_non_local_return = true - -### -# Controls when to generate a value for has_secure_token declarations. -#++ -Rails.application.config.active_record.generate_secure_token_on = :initialize - -### -# Configure Action View to use HTML5 standards-compliant sanitizers when they are supported on your -# platform. -# -# `Rails::HTML::Sanitizer.best_supported_vendor` will cause Action View to use HTML5-compliant -# sanitizers if they are supported, else fall back to HTML4 sanitizers. -# -# In previous versions of Rails, Action View always used `Rails::HTML4::Sanitizer` as its vendor. -#++ -Rails.application.config.action_view.sanitizer_vendor = Rails::HTML::Sanitizer.best_supported_vendor - -### -# Configure Action Text to use an HTML5 standards-compliant sanitizer when it is supported on your -# platform. -# -# `Rails::HTML::Sanitizer.best_supported_vendor` will cause Action Text to use HTML5-compliant -# sanitizers if they are supported, else fall back to HTML4 sanitizers. -# -# In previous versions of Rails, Action Text always used `Rails::HTML4::Sanitizer` as its vendor. -#++ -Rails.application.config.action_text.sanitizer_vendor = Rails::HTML::Sanitizer.best_supported_vendor - -### -# Configure the log level used by the DebugExceptions middleware when logging -# uncaught exceptions during requests. -#++ -Rails.application.config.action_dispatch.debug_exception_log_level = :error - -### -# Configure the test helpers in Action View, Action Dispatch, and rails-dom-testing to use HTML5 -# parsers. -# -# Nokogiri::HTML5 isn't supported on JRuby, so JRuby applications must set this to :html4. -# -# In previous versions of Rails, these test helpers always used an HTML4 parser. -#++ -Rails.application.config.dom_testing_default_html_version = :html5 From c093920b4ef10a67a0798df2e5cbde7a22a67a82 Mon Sep 17 00:00:00 2001 From: Fabio Lima Date: Sun, 14 Sep 2025 10:01:21 -0700 Subject: [PATCH 18/19] Fix deprecation warnings --- 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 3fc83d03..8f2df391 100644 --- a/spec/rails_helper.rb +++ b/spec/rails_helper.rb @@ -55,7 +55,7 @@ config.include ActiveSupport::Testing::TimeHelpers # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures - config.fixture_path = "#{::Rails.root}/spec/fixtures" + config.fixture_paths = ["#{Rails.root.join('spec', 'fixtures', '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 From e5787d000ae3a40f3bfc8bd4a1864c8bfda3b722 Mon Sep 17 00:00:00 2001 From: Fabio Lima Date: Sun, 14 Sep 2025 10:27:57 -0700 Subject: [PATCH 19/19] Fix bug on WelcomesIconComponent when welcomes is not supported, and add specs for the component --- app/assets/images/icons/error.svg | 2 + .../facilities/welcomes_icon_component.rb | 6 +- .../welcomes_icon_component_spec.rb | 193 ++++++++++++++++++ 3 files changed, 198 insertions(+), 3 deletions(-) create mode 100644 app/assets/images/icons/error.svg create mode 100644 spec/components/facilities/welcomes_icon_component_spec.rb diff --git a/app/assets/images/icons/error.svg b/app/assets/images/icons/error.svg new file mode 100644 index 00000000..b8f1acfa --- /dev/null +++ b/app/assets/images/icons/error.svg @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/app/components/facilities/welcomes_icon_component.rb b/app/components/facilities/welcomes_icon_component.rb index d92d5802..dceec405 100644 --- a/app/components/facilities/welcomes_icon_component.rb +++ b/app/components/facilities/welcomes_icon_component.rb @@ -1,6 +1,7 @@ # frozen_string_literal: true class Facilities::WelcomesIconComponent < ViewComponent::Base + ERROR_ICON = "error.svg" ICONS = { female: "female.svg", male: "male.svg", @@ -25,8 +26,6 @@ def initialize(welcomes, variant: :full) def call return call_icon if variant == :icon - tag.span "Error: #{@welcomes}", class: "tag is-danger" - tag.div class: "svg-icon ml-1" do helpers.inline_svg_tag(icon_location, size: "20px") end @@ -39,6 +38,7 @@ def call_icon end def icon_location - "icons/#{ICONS[@welcomes]}" + selected_icon = ICONS[@welcomes].presence || ERROR_ICON + "icons/#{selected_icon}" end end diff --git a/spec/components/facilities/welcomes_icon_component_spec.rb b/spec/components/facilities/welcomes_icon_component_spec.rb new file mode 100644 index 00000000..d3649702 --- /dev/null +++ b/spec/components/facilities/welcomes_icon_component_spec.rb @@ -0,0 +1,193 @@ +require "rails_helper" + +RSpec.describe Facilities::WelcomesIconComponent, type: :component do + subject(:component) { described_class.new(welcomes, variant: variant) } + + let(:variant) { :full } + + describe "with valid welcome types" do + described_class::ICONS.each do |welcome_type, expected_icon| + context "when welcomes is '#{welcome_type}'" do + let(:welcomes) { welcome_type } + + it "renders without error" do + expect { render_inline(component) }.not_to raise_exception + end + + context "with full variant" do + let(:variant) { :full } + + before do + render_inline(component) + end + + it "renders a div with svg-icon class" do + expect(rendered_content).to have_css("div.svg-icon.ml-1") + end + + it "renders the correct icon" do + expect(rendered_content).to have_css("svg") + end + end + + context "with icon variant" do + let(:variant) { :icon } + + before do + render_inline(component) + end + + it "renders a span with icon class" do + expect(rendered_content).to have_css("span.icon") + end + + it "renders the correct icon" do + expect(rendered_content).to have_css("svg") + end + + it "does not show error message for icon variant" do + expect(rendered_content).not_to have_css("span.tag.is-danger") + end + end + + describe "#icon_location" do + it "returns the correct icon path" do + expect(component.icon_location).to eq("icons/#{expected_icon}") + end + end + end + end + end + + describe "with string welcome types" do + context "when welcomes is a string that matches a valid type" do + let(:welcomes) { "female" } + + it "renders without error" do + expect { render_inline(component) }.not_to raise_exception + end + + it "converts string to symbol correctly" do + expect(component.icon_location).to eq("icons/female.svg") + end + end + + context "when welcomes is a camelCase string" do + let(:welcomes) { "maleTransgender" } + + it "converts camelCase to underscore" do + # The component should convert "maleTransgender" to "male_transgender" + expect(component.instance_variable_get(:@welcomes)).to eq(:male_transgender) + end + end + end + + describe "with invalid welcome types" do + context "when welcomes is not in the ICONS hash" do + let(:welcomes) { "invalid_type" } + + before do + render_inline(component) + end + + it "still attempts to render the icon div for full variant" do + expect(rendered_content).to have_css("div.svg-icon.ml-1") + end + end + + context "when welcomes is nil" do + let(:welcomes) { nil } + + before do + render_inline(component) + end + + it "handles nil gracefully" do + expect(rendered_content).to have_css("div.svg-icon.ml-1") + end + end + end + + describe "variant parameter" do + let(:welcomes) { :female } + + context "when variant is :full (default)" do + let(:variant) { :full } + + before do + render_inline(component) + end + + it "renders the full variant structure" do + expect(rendered_content).to have_css("div.svg-icon.ml-1") + end + end + + context "when variant is :icon" do + let(:variant) { :icon } + + before do + render_inline(component) + end + + it "renders only the icon variant structure" do + expect(rendered_content).to have_css("span.icon") + expect(rendered_content).not_to have_css("div.svg-icon") + end + end + + context "when variant is not specified" do + subject(:component) { described_class.new(welcomes) } + + let(:welcomes) { :female } + + before do + render_inline(component) + end + + it "defaults to full variant" do + expect(rendered_content).to have_css("div.svg-icon.ml-1") + end + end + end + + describe "logging" do + let(:welcomes) { :female } + + it "logs debug information during initialization" do + expect(Rails.logger).to receive(:debug) + described_class.new(welcomes) + end + end + + describe "all defined icon types" do + it "has icons defined for all expected welcome types" do + expected_types = %i[female male transgender children youth adult senior] + expect(described_class::ICONS.keys).to match_array(expected_types) + end + + it "has valid file extensions for all icons" do + described_class::ICONS.values.each do |icon_file| + expect(icon_file).to end_with(".svg") + end + end + end + + describe "icon_location method" do + context "when welcome type exists in ICONS" do + let(:welcomes) { :female } + + it "returns the correct path" do + expect(component.icon_location).to eq("icons/female.svg") + end + end + + context "when welcome type does not exist in ICONS" do + let(:welcomes) { :nonexistent } + + it "returns path with nil filename" do + expect(component.icon_location).to eq("icons/error.svg") + end + end + end +end