From fd44232ccf7ae1b450895296df21c0788be26f8e Mon Sep 17 00:00:00 2001 From: Splines Date: Sat, 6 Apr 2024 19:18:57 +0200 Subject: [PATCH 01/24] Upgrade Rails to v7.1 and run `bundle update` See the upgrade guide here: https://edgeguides.rubyonrails.org/upgrading_ruby_on_rails.html --- Gemfile | 2 +- Gemfile.lock | 440 +++++++++++++++++++++++++++------------------------ 2 files changed, 236 insertions(+), 206 deletions(-) diff --git a/Gemfile b/Gemfile index aa44445ae..e45ff6031 100644 --- a/Gemfile +++ b/Gemfile @@ -4,7 +4,7 @@ git_source(:github) { |repo| "https://github.com/#{repo}.git" } ruby "3.1.4" # Bundle edge Rails instead: gem 'rails', github: 'rails/rails' -gem "rails", "~> 7.0.4.3" +gem "rails", "~> 7.1.3" # Use dalli for caching to memcached in production gem "dalli", ">= 2.7" # Ruby wrapper for UglifyJS JavaScript compressor diff --git a/Gemfile.lock b/Gemfile.lock index 946c11b31..09ddaf2f4 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -10,11 +10,11 @@ GIT GIT remote: https://github.com/sunspot/sunspot.git - revision: 414a59413cb7333ba4b2cc7bc23a625c7a965e03 + revision: 41a311e9eff34df5ae7c51905574677dd474e91e glob: sunspot_rails/*.gemspec specs: sunspot_rails (2.6.0) - rails (>= 3) + rails (>= 5) sunspot (= 2.6.0) GIT @@ -28,125 +28,136 @@ GIT GIT remote: https://github.com/zdennis/activerecord-import.git - revision: 748309d1ae03fc1fe56d58e54c634a003408c706 + revision: e4e06bfa3bd0610878eaa4d1d537f5dccf57ccc4 branch: master specs: - activerecord-import (1.4.1) + activerecord-import (1.6.0) activerecord (>= 4.2) GEM remote: https://rubygems.org/ specs: Ascii85 (1.1.0) - RubyInline (3.13.0) + RubyInline (3.14.0) ZenTest (~> 4.3) ZenTest (4.12.1) - actioncable (7.0.4.3) - actionpack (= 7.0.4.3) - activesupport (= 7.0.4.3) + actioncable (7.1.3.2) + actionpack (= 7.1.3.2) + activesupport (= 7.1.3.2) nio4r (~> 2.0) websocket-driver (>= 0.6.1) - actionmailbox (7.0.4.3) - actionpack (= 7.0.4.3) - activejob (= 7.0.4.3) - activerecord (= 7.0.4.3) - activestorage (= 7.0.4.3) - activesupport (= 7.0.4.3) + zeitwerk (~> 2.6) + actionmailbox (7.1.3.2) + actionpack (= 7.1.3.2) + activejob (= 7.1.3.2) + activerecord (= 7.1.3.2) + activestorage (= 7.1.3.2) + activesupport (= 7.1.3.2) mail (>= 2.7.1) net-imap net-pop net-smtp - actionmailer (7.0.4.3) - actionpack (= 7.0.4.3) - actionview (= 7.0.4.3) - activejob (= 7.0.4.3) - activesupport (= 7.0.4.3) + actionmailer (7.1.3.2) + actionpack (= 7.1.3.2) + actionview (= 7.1.3.2) + activejob (= 7.1.3.2) + activesupport (= 7.1.3.2) mail (~> 2.5, >= 2.5.4) net-imap net-pop net-smtp - rails-dom-testing (~> 2.0) - actionpack (7.0.4.3) - actionview (= 7.0.4.3) - activesupport (= 7.0.4.3) - rack (~> 2.0, >= 2.2.0) + rails-dom-testing (~> 2.2) + actionpack (7.1.3.2) + actionview (= 7.1.3.2) + activesupport (= 7.1.3.2) + 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.4.3) - actionpack (= 7.0.4.3) - activerecord (= 7.0.4.3) - activestorage (= 7.0.4.3) - activesupport (= 7.0.4.3) + rails-dom-testing (~> 2.2) + rails-html-sanitizer (~> 1.6) + actiontext (7.1.3.2) + actionpack (= 7.1.3.2) + activerecord (= 7.1.3.2) + activestorage (= 7.1.3.2) + activesupport (= 7.1.3.2) globalid (>= 0.6.0) nokogiri (>= 1.8.5) - actionview (7.0.4.3) - activesupport (= 7.0.4.3) + actionview (7.1.3.2) + activesupport (= 7.1.3.2) builder (~> 3.1) - erubi (~> 1.4) - rails-dom-testing (~> 2.0) - rails-html-sanitizer (~> 1.1, >= 1.2.0) - active_model_serializers (0.10.13) - actionpack (>= 4.1, < 7.1) - activemodel (>= 4.1, < 7.1) + erubi (~> 1.11) + rails-dom-testing (~> 2.2) + rails-html-sanitizer (~> 1.6) + active_model_serializers (0.10.14) + actionpack (>= 4.1) + activemodel (>= 4.1) case_transform (>= 0.2) jsonapi-renderer (>= 0.1.1.beta1, < 0.3) active_record_union (1.3.0) activerecord (>= 4.0) - activejob (7.0.4.3) - activesupport (= 7.0.4.3) + activejob (7.1.3.2) + activesupport (= 7.1.3.2) globalid (>= 0.3.6) - activemodel (7.0.4.3) - activesupport (= 7.0.4.3) - activerecord (7.0.4.3) - activemodel (= 7.0.4.3) - activesupport (= 7.0.4.3) - activerecord-nulldb-adapter (0.9.0) - activerecord (>= 5.2.0, < 7.1) - activestorage (7.0.4.3) - actionpack (= 7.0.4.3) - activejob (= 7.0.4.3) - activerecord (= 7.0.4.3) - activesupport (= 7.0.4.3) + activemodel (7.1.3.2) + activesupport (= 7.1.3.2) + activerecord (7.1.3.2) + activemodel (= 7.1.3.2) + activesupport (= 7.1.3.2) + timeout (>= 0.4.0) + activerecord-nulldb-adapter (1.0.1) + activerecord (>= 5.2.0, < 7.2) + activestorage (7.1.3.2) + actionpack (= 7.1.3.2) + activejob (= 7.1.3.2) + activerecord (= 7.1.3.2) + activesupport (= 7.1.3.2) marcel (~> 1.0) - mini_mime (>= 1.1.0) - activesupport (7.0.4.3) + activesupport (7.1.3.2) + base64 + bigdecimal concurrent-ruby (~> 1.0, >= 1.0.2) + connection_pool (>= 2.2.5) + drb i18n (>= 1.6, < 2) minitest (>= 5.1) + mutex_m tzinfo (~> 2.0) acts_as_list (1.1.0) activerecord (>= 4.2) acts_as_tree (2.9.1) activerecord (>= 3.0.0) acts_as_votable (0.14.0) - addressable (2.8.2) + addressable (2.8.6) public_suffix (>= 2.0.2, < 6.0) afm (0.2.2) ast (2.4.2) - autoprefixer-rails (10.4.13.0) + autoprefixer-rails (10.4.16.0) execjs (~> 2) babel-source (5.8.35) babel-transpiler (0.7.0) babel-source (>= 4.0, < 6) execjs (~> 2.0) - barby (0.6.8) - bcrypt (3.1.18) + barby (0.6.9) + base64 (0.2.0) + bcrypt (3.1.20) + bigdecimal (3.1.7) bindex (0.8.1) - bootsnap (1.16.0) + bootsnap (1.18.3) msgpack (~> 1.2) - bootstrap (5.3.1) + bootstrap (5.3.2) autoprefixer-rails (>= 9.1.0) popper_js (>= 2.11.8, < 3) - sassc-rails (>= 2.0.0) - bootstrap_form (5.1.0) - actionpack (>= 5.2) - activemodel (>= 5.2) + bootstrap_form (5.4.0) + actionpack (>= 6.1) + activemodel (>= 6.1) builder (3.2.4) byebug (11.1.3) cancancan (3.5.0) case_transform (0.2) activesupport + childprocess (5.0.0) choice (0.2.0) chunky_png (1.4.0) clipboard-rails (1.7.1) @@ -157,12 +168,12 @@ GEM coffee-script-source execjs coffee-script-source (1.12.2) - commontator (7.0.0) + commontator (7.0.1) rails (>= 6.0) sprockets-rails will_paginate - concurrent-ruby (1.2.2) - connection_pool (2.4.0) + concurrent-ruby (1.2.3) + connection_pool (2.4.1) content_disposition (1.0.0) coveralls (0.7.1) multi_json (~> 1.3) @@ -171,48 +182,48 @@ GEM term-ansicolor thor crass (1.0.6) - css_parser (1.14.0) + css_parser (1.16.0) addressable - cypress-on-rails (1.13.1) + cypress-on-rails (1.17.0) rack - dalli (3.2.4) + dalli (3.2.8) database_cleaner (2.0.2) database_cleaner-active_record (>= 2, < 3) database_cleaner-active_record (2.1.0) activerecord (>= 5.a) database_cleaner-core (~> 2.0.0) database_cleaner-core (2.0.1) - date (3.3.3) + date (3.3.4) db_text_search (1.0.0) activerecord (>= 4.1.15) - devise (4.9.1) + devise (4.9.3) bcrypt (~> 3.0) orm_adapter (~> 0.1) railties (>= 4.1.0) responders warden (~> 1.2.3) devise-bootstrap-views (1.1.0) - diff-lcs (1.5.0) + diff-lcs (1.5.1) docile (1.4.0) - domain_name (0.5.20190701) - unf (>= 0.0.5, < 1.0.0) - down (5.4.0) + domain_name (0.6.20240107) + down (5.4.1) addressable (~> 2.8) + drb (2.2.1) erubi (1.12.0) erubis (2.7.0) - et-orbi (1.2.7) + et-orbi (1.2.11) tzinfo exception_handler (0.8.0.2) bundler rails (>= 4.2.0) responders - execjs (2.8.1) - factory_bot (6.2.1) + execjs (2.9.1) + factory_bot (6.4.6) activesupport (>= 5.0.0) - factory_bot_rails (6.2.0) - factory_bot (~> 6.2.0) + factory_bot_rails (6.4.3) + factory_bot (~> 6.4) railties (>= 5.0.0) - faker (3.1.1) + faker (3.3.1) i18n (>= 1.8.11, < 2) faraday (1.10.3) faraday-em_http (~> 1.0) @@ -237,34 +248,34 @@ GEM faraday-patron (1.0.0) faraday-rack (1.0.0) faraday-retry (1.0.3) - fastimage (2.2.6) - ffi (1.15.5) + fastimage (2.3.1) + ffi (1.16.3) filesize (0.2.0) - friendly_id (5.5.0) + friendly_id (5.5.1) activerecord (>= 4.0.0) - fugit (1.8.1) + fugit (1.10.1) et-orbi (~> 1, >= 1.2.7) raabro (~> 1.4) fuzzy-string-match (1.0.1) RubyInline (>= 3.8.6) - globalid (1.1.0) - activesupport (>= 5.0) - globalize (6.2.1) - activemodel (>= 4.2, < 7.1) - activerecord (>= 4.2, < 7.1) + globalid (1.2.1) + activesupport (>= 6.1) + globalize (6.3.0) + activemodel (>= 4.2, < 7.2) + activerecord (>= 4.2, < 7.2) request_store (~> 1.0) globalize-accessors (0.3.0) globalize (>= 5.0.0) hashery (2.1.2) highline (2.1.0) - html-pipeline (2.14.3) - activesupport (>= 2) - nokogiri (>= 1.4) + html-pipeline (3.1.0) + selma (~> 0.1) + zeitwerk (~> 2.5) htmlentities (4.3.4) http-accept (1.7.0) http-cookie (1.0.5) domain_name (~> 0.5) - i18n (1.14.1) + i18n (1.14.4) concurrent-ruby (~> 1.0) image_processing (1.12.2) mini_magick (>= 4.9.5, < 5) @@ -272,19 +283,23 @@ GEM inline_svg (1.9.0) activesupport (>= 3.0) nokogiri (>= 1.6) + io-console (0.7.2) + irb (1.12.0) + rdoc + reline (>= 0.4.2) jbuilder (2.11.5) actionview (>= 5.0.0) activesupport (>= 5.0.0) - jquery-rails (4.5.1) + jquery-rails (4.6.0) rails-dom-testing (>= 1, < 3) railties (>= 4.2.0) thor (>= 0.14, < 2.0) - jquery-ui-rails (6.0.1) + jquery-ui-rails (7.0.0) railties (>= 3.2.16) js-routes (1.4.9) railties (>= 4) sprockets-rails - json (2.6.3) + json (2.7.2) jsonapi-renderer (0.2.2) kaminari (1.2.2) activesupport (>= 4.1.0) @@ -301,8 +316,8 @@ GEM kaminari-i18n (0.5.0) kaminari rails - katex (0.9.0) - execjs (~> 2.7) + katex (0.10.0) + execjs (~> 2.8) kramdown (2.4.0) rexml kramdown-math-katex (1.0.1) @@ -311,12 +326,13 @@ GEM kramdown-parser-gfm (1.1.0) kramdown (~> 2.0) language_server-protocol (3.17.0.3) - launchy (2.5.2) + launchy (3.0.0) addressable (~> 2.8) + childprocess (~> 5.0) listen (3.0.8) rb-fsevent (~> 0.9, >= 0.9.4) rb-inotify (~> 0.9, >= 0.9.7) - loofah (2.21.3) + loofah (2.22.0) crass (~> 1.0.2) nokogiri (>= 1.12.0) mail (2.8.1) @@ -324,30 +340,30 @@ GEM net-imap net-pop net-smtp - marcel (1.0.2) - method_source (1.0.0) - mime-types (3.4.1) + marcel (1.0.4) + mime-types (3.5.2) mime-types-data (~> 3.2015) - mime-types-data (3.2023.0218.1) + mime-types-data (3.2024.0305) mini_magick (4.12.0) - mini_mime (1.1.2) - minitest (5.19.0) - msgpack (1.7.0) + mini_mime (1.1.5) + minitest (5.22.3) + msgpack (1.7.2) multi_json (1.15.0) - multipart-post (2.3.0) + multipart-post (2.4.0) mustache (1.1.1) - net-imap (0.3.4) + mutex_m (0.2.0) + net-imap (0.4.10) date net-protocol net-pop (0.1.2) net-protocol - net-protocol (0.2.1) + net-protocol (0.2.2) timeout - net-smtp (0.3.3) + net-smtp (0.5.0) net-protocol netrc (0.11.0) - nio4r (2.5.8) - nokogiri (1.15.4-x86_64-linux) + nio4r (2.7.1) + nokogiri (1.16.3-x86_64-linux) racc (~> 1.4) onebox (2.2.19) addressable (~> 2.8.0) @@ -358,22 +374,22 @@ GEM sanitize options (2.3.2) orm_adapter (0.5.0) - pairing_heap (3.0.0) - parallel (1.23.0) - parser (3.2.2.4) + pairing_heap (3.1.0) + parallel (1.24.0) + parser (3.3.0.5) ast (~> 2.4.1) racc - pdf-reader (2.11.0) + pdf-reader (2.12.0) Ascii85 (~> 1.0) afm (~> 0.2.1) hashery (~> 2.0) ruby-rc4 ttfunk - pg (1.4.6) - pgreset (0.3) + pg (1.5.6) + pgreset (0.4) popper_js (2.11.8) pr_geohash (1.0.0) - premailer (1.21.0) + premailer (1.23.0) addressable css_parser (>= 1.12.0) htmlentities (>= 4.0.0) @@ -384,34 +400,41 @@ GEM progress_bar (1.3.3) highline (>= 1.6, < 3) options (~> 2.3.0) - prometheus_exporter (2.0.8) + prometheus_exporter (2.1.0) webrick - public_suffix (5.0.1) - puma (6.3.1) + psych (5.1.2) + stringio + public_suffix (5.0.5) + puma (6.4.2) nio4r (~> 2.0) - pundit (2.3.0) + pundit (2.3.1) activesupport (>= 3.0.0) raabro (1.4.0) - racc (1.7.1) - rack (2.2.8) - rack-proxy (0.7.6) + racc (1.7.3) + rack (3.0.10) + rack-proxy (0.7.7) rack + rack-session (2.0.0) + rack (>= 3.0.0) rack-test (2.1.0) rack (>= 1.3) - rails (7.0.4.3) - actioncable (= 7.0.4.3) - actionmailbox (= 7.0.4.3) - actionmailer (= 7.0.4.3) - actionpack (= 7.0.4.3) - actiontext (= 7.0.4.3) - actionview (= 7.0.4.3) - activejob (= 7.0.4.3) - activemodel (= 7.0.4.3) - activerecord (= 7.0.4.3) - activestorage (= 7.0.4.3) - activesupport (= 7.0.4.3) + rackup (2.1.0) + rack (>= 3) + webrick (~> 1.8) + rails (7.1.3.2) + actioncable (= 7.1.3.2) + actionmailbox (= 7.1.3.2) + actionmailer (= 7.1.3.2) + actionpack (= 7.1.3.2) + actiontext (= 7.1.3.2) + actionview (= 7.1.3.2) + activejob (= 7.1.3.2) + activemodel (= 7.1.3.2) + activerecord (= 7.1.3.2) + activestorage (= 7.1.3.2) + activesupport (= 7.1.3.2) bundler (>= 1.15.0) - railties (= 7.0.4.3) + railties (= 7.1.3.2) rails-dom-testing (2.2.0) activesupport (>= 5.0.0) minitest @@ -424,29 +447,34 @@ GEM rails-html-sanitizer (1.6.0) loofah (~> 2.21) nokogiri (~> 1.14) - rails-i18n (7.0.6) + rails-i18n (7.0.9) i18n (>= 0.7, < 2) railties (>= 6.0.0, < 8) rails_gravatar (1.0.4) actionview - railties (7.0.4.3) - actionpack (= 7.0.4.3) - activesupport (= 7.0.4.3) - method_source + railties (7.1.3.2) + actionpack (= 7.1.3.2) + activesupport (= 7.1.3.2) + 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.0.6) + rake (13.2.1) rb-fsevent (0.11.2) rb-inotify (0.10.1) ffi (~> 1.0) - redis-client (0.14.1) + rdoc (6.6.3.1) + psych (>= 4.0.0) + redis-client (0.21.1) connection_pool - regexp_parser (2.8.2) - request_store (1.5.1) + regexp_parser (2.9.0) + reline (0.5.0) + io-console (~> 0.5) + request_store (1.6.0) rack (>= 1.4) - responders (3.1.0) + responders (3.1.1) actionpack (>= 5.2) railties (>= 5.2) rest-client (2.1.0) @@ -454,65 +482,66 @@ GEM http-cookie (>= 1.0.2, < 2.0) mime-types (>= 1.16, < 4.0) netrc (~> 0.8) - rexml (3.2.5) - rgl (0.6.2) - pairing_heap (>= 0.3.0) + rexml (3.2.6) + rgl (0.6.6) + pairing_heap (>= 0.3, < 4.0) rexml (~> 3.2, >= 3.2.4) stream (~> 0.5.3) rinku (2.0.6) - rqrcode (2.1.2) + rqrcode (2.2.0) chunky_png (~> 1.0) rqrcode_core (~> 1.0) rqrcode_core (1.2.0) - rsolr (2.5.0) + rsolr (2.6.0) builder (>= 2.1.2) faraday (>= 0.9, < 3, != 2.0.0) - rspec-core (3.12.1) - rspec-support (~> 3.12.0) - rspec-expectations (3.12.2) + rspec-core (3.13.0) + rspec-support (~> 3.13.0) + rspec-expectations (3.13.0) diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.12.0) - rspec-mocks (3.12.5) + rspec-support (~> 3.13.0) + rspec-mocks (3.13.0) diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.12.0) - rspec-rails (6.0.1) + rspec-support (~> 3.13.0) + rspec-rails (6.1.2) actionpack (>= 6.1) activesupport (>= 6.1) railties (>= 6.1) - rspec-core (~> 3.11) - rspec-expectations (~> 3.11) - rspec-mocks (~> 3.11) - rspec-support (~> 3.11) - rspec-support (3.12.0) - rubocop (1.57.2) + rspec-core (~> 3.13) + rspec-expectations (~> 3.13) + rspec-mocks (~> 3.13) + rspec-support (~> 3.13) + rspec-support (3.13.1) + rubocop (1.62.1) json (~> 2.3) language_server-protocol (>= 3.17.0) parallel (~> 1.10) - parser (>= 3.2.2.4) + parser (>= 3.3.0.2) rainbow (>= 2.2.2, < 4.0) regexp_parser (>= 1.8, < 3.0) rexml (>= 3.2.5, < 4.0) - rubocop-ast (>= 1.28.1, < 2.0) + rubocop-ast (>= 1.31.1, < 2.0) ruby-progressbar (~> 1.7) unicode-display_width (>= 2.4.0, < 3.0) - rubocop-ast (1.30.0) - parser (>= 3.2.1.0) - rubocop-performance (1.19.1) - rubocop (>= 1.7.0, < 2.0) - rubocop-ast (>= 0.4.0) - rubocop-rails (2.22.1) + rubocop-ast (1.31.2) + parser (>= 3.3.0.4) + rubocop-performance (1.21.0) + rubocop (>= 1.48.1, < 2.0) + rubocop-ast (>= 1.31.1, < 2.0) + rubocop-rails (2.24.1) activesupport (>= 4.2.0) rack (>= 1.1) rubocop (>= 1.33.0, < 2.0) + rubocop-ast (>= 1.31.1, < 2.0) ruby-graphviz (1.2.5) rexml ruby-progressbar (1.13.0) ruby-rc4 (0.1.5) - ruby-vips (2.1.4) + ruby-vips (2.2.1) ffi (~> 1.12) ruby2_keywords (0.0.5) rubyzip (2.3.2) - sanitize (6.0.1) + sanitize (6.1.0) crass (~> 1.0.2) nokogiri (>= 1.12.0) sass-rails (6.0.0) @@ -525,20 +554,22 @@ GEM sprockets (> 3.0) sprockets-rails tilt - selenium-webdriver (4.8.6) + selenium-webdriver (4.19.0) + base64 (~> 0.2) rexml (~> 3.2, >= 3.2.5) rubyzip (>= 1.2.2, < 3.0) websocket (~> 1.0) + selma (0.2.2-x86_64-linux) semantic_range (3.0.0) - shrine (3.4.0) + shrine (3.5.0) content_disposition (~> 1.0) down (~> 5.1) - sidekiq (7.0.9) + sidekiq (7.2.2) concurrent-ruby (< 2) connection_pool (>= 2.3.0) rack (>= 2.2.4) - redis-client (>= 0.11.0) - sidekiq-cron (1.10.0) + redis-client (>= 0.19.0) + sidekiq-cron (1.12.0) fugit (~> 1.8) globalid (>= 1.0.1) sidekiq (>= 6) @@ -555,27 +586,28 @@ GEM spring-watcher-listen (2.0.1) listen (>= 2.7, < 4.0) spring (>= 1.2, < 3.0) - sprockets (4.2.0) + sprockets (4.2.1) concurrent-ruby (~> 1.0) rack (>= 2.2.4, < 4) sprockets-es6 (0.9.2) babel-source (>= 5.8.11) babel-transpiler sprockets (>= 3.0.0) - sqlite3 (1.6.2-x86_64-linux) + sqlite3 (1.7.3-x86_64-linux) stream (0.5.5) streamio-ffmpeg (3.0.2) multi_json (~> 1.8) + stringio (3.1.0) sunspot (2.6.0) pr_geohash (~> 1.0) rsolr (>= 1.1.1, < 3) sunspot_solr (2.6.0) sync (0.5.0) - term-ansicolor (1.7.1) + term-ansicolor (1.7.2) tins (~> 1.0) - terser (1.1.14) + terser (1.2.2) execjs (>= 0.3.0, < 3) - thor (1.2.2) + thor (1.3.1) thredded (1.1.0) active_record_union (>= 1.3.0) autoprefixer-rails @@ -597,26 +629,24 @@ GEM sassc-rails (>= 2.0.0) sprockets-es6 timeago_js (>= 3.0.2.2) - tilt (2.2.0) + tilt (2.3.0) timeago_js (3.0.2.2) - timeout (0.3.2) + timeout (0.4.1) tins (1.32.1) sync trix-rails (2.4.0) rails (> 4.1) - ttfunk (1.7.0) + ttfunk (1.8.0) + bigdecimal (~> 3.1) turbolinks (5.2.1) turbolinks-source (~> 5.2) turbolinks-source (5.2.0) tzinfo (2.0.6) concurrent-ruby (~> 1.0) - unf (0.1.4) - unf_ext - unf_ext (0.0.8.2) unicode-display_width (2.5.0) warden (1.2.9) rack (>= 2.0.9) - web-console (4.2.0) + web-console (4.2.1) actionview (>= 6.0.0) activemodel (>= 6.0.0) bindex (>= 0.4.0) @@ -631,12 +661,12 @@ GEM railties (>= 5.2) semantic_range (>= 2.3.0) webrick (1.8.1) - websocket (1.2.9) - websocket-driver (0.7.5) + websocket (1.2.10) + websocket-driver (0.7.6) websocket-extensions (>= 0.1.0) websocket-extensions (0.1.5) - will_paginate (3.3.1) - zeitwerk (2.6.11) + will_paginate (4.0.0) + zeitwerk (2.6.13) PLATFORMS x86_64-linux @@ -694,7 +724,7 @@ DEPENDENCIES prometheus_exporter puma (< 7) rack - rails (~> 7.0.4.3) + rails (~> 7.1.3) rails-erd rails-i18n responders From 456ed14421c90d2812c4889374b12028ac7f53c3 Mon Sep 17 00:00:00 2001 From: Splines Date: Sat, 6 Apr 2024 20:38:24 +0200 Subject: [PATCH 02/24] Use older version of `html-parser` for `thredded` See https://github.com/thredded/thredded/issues/979 --- Gemfile | 1 + Gemfile.lock | 10 +++++----- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/Gemfile b/Gemfile index e45ff6031..7e980e5a8 100644 --- a/Gemfile +++ b/Gemfile @@ -72,6 +72,7 @@ gem "faraday", "~> 1.8" gem "fuzzy-string-match" gem "globalize" gem "globalize-accessors" +gem "html-pipeline", "~> 2.14" gem "jquery-rails" gem "jquery-ui-rails" gem "js-routes", "1.4.9" diff --git a/Gemfile.lock b/Gemfile.lock index 09ddaf2f4..91f8be12f 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -182,7 +182,7 @@ GEM term-ansicolor thor crass (1.0.6) - css_parser (1.16.0) + css_parser (1.17.0) addressable cypress-on-rails (1.17.0) rack @@ -268,9 +268,9 @@ GEM globalize (>= 5.0.0) hashery (2.1.2) highline (2.1.0) - html-pipeline (3.1.0) - selma (~> 0.1) - zeitwerk (~> 2.5) + html-pipeline (2.14.3) + activesupport (>= 2) + nokogiri (>= 1.4) htmlentities (4.3.4) http-accept (1.7.0) http-cookie (1.0.5) @@ -559,7 +559,6 @@ GEM rexml (~> 3.2, >= 3.2.5) rubyzip (>= 1.2.2, < 3.0) websocket (~> 1.0) - selma (0.2.2-x86_64-linux) semantic_range (3.0.0) shrine (3.5.0) content_disposition (~> 1.0) @@ -703,6 +702,7 @@ DEPENDENCIES fuzzy-string-match globalize globalize-accessors + html-pipeline (~> 2.14) image_processing jbuilder jquery-rails From 6aee7bb3323ab7f86b3569ff0517927db611355c Mon Sep 17 00:00:00 2001 From: Splines Date: Sat, 6 Apr 2024 20:39:45 +0200 Subject: [PATCH 03/24] Use new `config.autoload_lib` in Rails 7.1 See https://edgeguides.rubyonrails.org/upgrading_ruby_on_rails.html#config-autoload-lib-and-config-autoload-lib-once Eager loading is on by default for production. --- config/application.rb | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/config/application.rb b/config/application.rb index 85776e7ff..2f2d8859f 100644 --- a/config/application.rb +++ b/config/application.rb @@ -12,17 +12,8 @@ class Application < Rails::Application config.load_defaults(7.0) config.autoloader = :zeitwerk - # Autoload lib extensions path (ignore all other subdirectories of lib/) - lib_path = Rails.root.join("lib") - config.autoload_paths << lib_path - config.eager_load_paths << lib_path - Rails.autoloaders.main.ignore( - lib_path.join("assets"), - lib_path.join("collectors"), - lib_path.join("core_ext"), - lib_path.join("scrapers"), - lib_path.join("tasks") - ) + # Autoload lib extensions path + config.autoload_lib(ignore: ["assets", "collectors", "core_ext", "scrapers", "tasks"]) config.i18n.default_locale = :de config.i18n.fallbacks = [:en] From 97ea0dac29e40f6338d8a45af03ae6711e90ade0 Mon Sep 17 00:00:00 2001 From: Splines Date: Sat, 6 Apr 2024 20:43:13 +0200 Subject: [PATCH 04/24] Remove unused app environment variables usage The file `config/app_environment_variables.rb` does not exist in our codebase anymore. --- .gitignore | 1 - config/environment.rb | 4 ---- 2 files changed, 5 deletions(-) diff --git a/.gitignore b/.gitignore index a3800f0df..fa78b9564 100644 --- a/.gitignore +++ b/.gitignore @@ -43,7 +43,6 @@ coverage /public/uploads # Ignore environment variables -/config/app_environment_variables.rb completed_initial_run /public/uploads.zip /public/pdfcomprezzor/pdfcomprezzor.wasm diff --git a/config/environment.rb b/config/environment.rb index 336dd862b..cac531577 100644 --- a/config/environment.rb +++ b/config/environment.rb @@ -1,9 +1,5 @@ # Load the Rails application. require_relative "application" -# Load the app's custom environment variables here, so that they are loaded before environments/*.rb -app_environment_variables = Rails.root.join("config/app_environment_variables.rb").to_s -load(app_environment_variables) if File.exist?(app_environment_variables) - # Initialize the Rails application. Rails.application.initialize! From e066740e3110e8ad97c634df995d4f9b61a5d4f4 Mon Sep 17 00:00:00 2001 From: Splines Date: Sun, 7 Apr 2024 00:06:53 +0200 Subject: [PATCH 05/24] Run `bin/rails app:update` to update configurations --- bin/setup | 20 ++--- config/application.rb | 2 + config/environments/development.rb | 14 +++- config/environments/production.rb | 83 +++++-------------- config/environments/test.rb | 31 +++---- .../initializers/content_security_policy.rb | 13 ++- .../initializers/filter_parameter_logging.rb | 6 +- config/initializers/inflections.rb | 8 +- config/initializers/permissions_policy.rb | 20 +++-- 9 files changed, 82 insertions(+), 115 deletions(-) diff --git a/bin/setup b/bin/setup index 90700ac4f..2cc479483 100755 --- a/bin/setup +++ b/bin/setup @@ -2,10 +2,10 @@ require "fileutils" # path to your application root. -APP_ROOT = File.expand_path('..', __dir__) +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 @@ -13,24 +13,24 @@ FileUtils.chdir APP_ROOT do # This script is idempotent, so that you can run it at any time and get an expectable outcome. # Add necessary setup steps to this file. - puts '== Installing dependencies ==' - system! 'gem install bundler --conservative' - system('bundle check') || system!('bundle install') + puts "== Installing dependencies ==" + system! "gem install bundler --conservative" + system("bundle check") || system!("bundle install") # Install JavaScript dependencies system! 'bin/yarn' # puts "\n== Copying sample files ==" - # unless File.exist?('config/database.yml') - # FileUtils.cp 'config/database.yml.sample', 'config/database.yml' + # unless File.exist?("config/database.yml") + # FileUtils.cp "config/database.yml.sample", "config/database.yml" # end puts "\n== Preparing database ==" - system! 'bin/rails db:prepare' + system! "bin/rails db:prepare" puts "\n== Removing old logs and tempfiles ==" - system! 'bin/rails log:clear tmp:clear' + system! "bin/rails log:clear tmp:clear" puts "\n== Restarting application server ==" - system! 'bin/rails restart' + system! "bin/rails restart" end diff --git a/config/application.rb b/config/application.rb index 2f2d8859f..d3bff2358 100644 --- a/config/application.rb +++ b/config/application.rb @@ -18,7 +18,9 @@ class Application < Rails::Application config.i18n.default_locale = :de config.i18n.fallbacks = [:en] config.i18n.available_locales = [:de, :en] + config.i18n.raise_on_missing_translations = true config.time_zone = "Berlin" + # config.eager_load_paths << Rails.root.join("extras") # Make `form_with` generate remote forms by default. config.action_view.form_with_generates_remote_forms = true diff --git a/config/environments/development.rb b/config/environments/development.rb index 2ce769377..c6529aa9d 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -1,10 +1,10 @@ Rails.application.configure do # Settings specified here will take precedence over those in config/application.rb. - # In the development environment your application's code is reloaded on - # every request. This slows down response time but is perfect for development + # 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 @@ -12,6 +12,9 @@ # Show full error reports. config.consider_all_requests_local = true + # Enable server timing + config.server_timing = true + # Enable/disable caching. By default caching is disabled. # Run rails dev:cache to toggle caching. if Rails.root.join("tmp/caching-dev.txt").exist? @@ -33,7 +36,7 @@ config.i18n.default_locale = :de - # Don't care if the mailer can't send. + # Mail settings config.action_mailer.perform_deliveries = true config.action_mailer.default_url_options = { host: "localhost", port: 3000 } config.action_mailer.delivery_method = :smtp @@ -46,6 +49,9 @@ # Print deprecation notices to the Rails logger. config.active_support.deprecation = :log + # Raise exceptions for disallowed deprecations. + config.active_support.disallowed_deprecation = :raise + # Raise an error on page load if there are pending migrations. config.active_record.migration_error = :page_load diff --git a/config/environments/production.rb b/config/environments/production.rb index ae9c17db1..18e070a38 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -2,7 +2,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 @@ -11,45 +11,43 @@ config.eager_load = true # Full error reports are disabled and caching is turned on. - config.consider_all_requests_local = false + 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). - # config.require_master_key = true + # 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 - # Apache or NGINX already handles this. + # Disable serving static files from `public/`, relying on NGINX/Apache to do so instead. config.public_file_server.enabled = ENV["RAILS_SERVE_STATIC_FILES"].present? # Compress CSS using a preprocessor. config.assets.css_compressor = :sass config.assets.js_compressor = :terser - # 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. - # config.action_controller.asset_host = 'http://assets.example.com' - # Specifies the header that your server uses for sending files. - # config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache + # config.action_dispatch.x_sendfile_header = "X-Sendfile" # for Apache config.action_dispatch.x_sendfile_header = "X-Accel-Redirect" # for NGINX # Store uploaded files on the local file system (see config/storage.yml for options). config.active_storage.service = :local - # Mount Action Cable outside main process or domain - # config.action_cable.mount_path = nil - # config.action_cable.url = 'wss://example.com/cable' - # config.action_cable.allowed_request_origins = [ 'http://example.com', /http:\/\/example.*/ ] + # Use default logging formatter so that PID and timestamp are not suppressed. + config.log_formatter = Logger::Formatter.new - # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. - # config.force_ssl = true + if ENV["RAILS_LOG_TO_STDOUT"].present? + config.logger = ActiveSupport::Logger.new($stdout) + .tap { |logger| logger.formatter = config.log_formatter } + .then { |logger| ActiveSupport::TaggedLogging.new(logger) } + end # Use the lowest log level to ensure availability of diagnostic information # when problems arise. - config.log_level = :warn + config.log_level = :info # Prepend all log lines with the following tags. config.log_tags = [:request_id] @@ -57,7 +55,7 @@ # Use a different cache store in production. config.cache_store = :mem_cache_store, ENV.fetch("MEMCACHED_SERVER") - # Use a real queuing backend for Active Job (and separate queues per environment) + # Use a real queuing backend for Active Job (and separate queues per environment). # config.active_job.queue_adapter = :resque # config.active_job.queue_name_prefix = "mampf_#{Rails.env}" config.action_mailer.perform_caching = false @@ -75,52 +73,9 @@ password: ENV.fetch("MAMPF_EMAIL_PASSWORD") } - # Ignore bad email addresses and do not raise email delivery errors. - # Set this to true and configure the email server for immediate delivery to raise delivery errors. - # config.action_mailer.raise_delivery_errors = false - - # Enable locale fallbacks for I18n (makes lookups for any locale fall back to - # the I18n.default_locale when a translation cannot be found). - # config.i18n.default_locale = :de - # config.i18n.fallbacks = [:en] - - # Send deprecation notices to registered listeners. + # Don't log any deprecations. config.active_support.deprecation = :notify - # 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 - # Inserts middleware to perform automatic connection switching. - # The `database_selector` hash is used to pass options to the DatabaseSelector - # middleware. The `delay` is used to determine how long to wait after a write - # to send a subsequent read to the primary. - # - # The `database_resolver` class is used by the middleware to determine which - # database is appropriate to use based on the time delay. - # - # The `database_resolver_context` class is used by the middleware to set - # timestamps for the last write to the primary. The resolver uses the context - # class timestamps to determine how long to wait before reading from the - # replica. - # - # By default Rails will store a last write timestamp in the session. The - # DatabaseSelector middleware is designed as such you can define your own - # strategy for connection switching and pass that into the middleware through - # these configuration options. - # config.active_record.database_selector = { delay: 2.seconds } - # config.active_record.database_resolver = ActiveRecord::Middleware::DatabaseSelector::Resolver - # config.active_record.database_resolver_context = \ - # ActiveRecord::Middleware::DatabaseSelector::Resolver::Session end diff --git a/config/environments/test.rb b/config/environments/test.rb index 5ce664ab7..213a0147e 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -6,12 +6,14 @@ Rails.application.configure do # Settings specified here will take precedence over those in config/application.rb. - config.cache_classes = false + # While tests run files are not watched, reloading is not necessary. + config.enable_reloading = false - # Do not eager load code on boot. This avoids loading your whole application - # just for the purpose of running a single test. If you are using a tool that - # preloads Rails for running tests, you may have to set it to true. - config.eager_load = false + # 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. config.public_file_server.enabled = true @@ -20,12 +22,12 @@ } # Show full error reports and disable caching. - config.consider_all_requests_local = true + config.consider_all_requests_local = true 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 = :none # Disable request forgery protection in test environment. config.action_controller.allow_forgery_protection = false @@ -50,16 +52,17 @@ # Tell Active Support which deprecation messages to disallow. config.active_support.disallowed_deprecation_warnings = [] - # Raises error for missing translations. - # config.i18n.raise_on_missing_translations = true - # Don't care if the mailer can't send. + # Internationlization + config.i18n.default_locale = :de + config.i18n.raise_on_missing_translations = true + + # Mail config.action_mailer.perform_deliveries = true config.action_mailer.default_url_options = { host: "localhost", port: 3000 } config.action_mailer.raise_delivery_errors = true config.action_mailer.perform_caching = false - config.i18n.default_locale = :de - # 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/content_security_policy.rb b/config/initializers/content_security_policy.rb index 3621f97f8..b3076b38f 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/filter_parameter_logging.rb b/config/initializers/filter_parameter_logging.rb index adc6568ce..274d593c7 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/inflections.rb b/config/initializers/inflections.rb index ac033bf9d..3860f659e 100644 --- a/config/initializers/inflections.rb +++ b/config/initializers/inflections.rb @@ -4,13 +4,13 @@ # are locale specific, and you may define rules for as many different # locales as you wish. All of these examples are active by default: # ActiveSupport::Inflector.inflections(:en) do |inflect| -# inflect.plural /^(ox)$/i, '\1en' -# inflect.singular /^(ox)en/i, '\1' -# inflect.irregular 'person', 'people' +# inflect.plural /^(ox)$/i, "\\1en" +# inflect.singular /^(ox)en/i, "\\1" +# inflect.irregular "person", "people" # inflect.uncountable %w( fish sheep ) # end # These inflection rules are supported but not enabled by default: # ActiveSupport::Inflector.inflections(:en) do |inflect| -# inflect.acronym 'RESTful' +# inflect.acronym "RESTful" # end diff --git a/config/initializers/permissions_policy.rb b/config/initializers/permissions_policy.rb index 00f64d71b..7db3b9577 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 1236c1bbbdbafa6a5e639d7d8dadf2851f317d06 Mon Sep 17 00:00:00 2001 From: Splines Date: Sun, 7 Apr 2024 00:07:16 +0200 Subject: [PATCH 06/24] Add new framework defaults for Rails 7.1 file --- .../new_framework_defaults_7_1.rb | 284 ++++++++++++++++++ 1 file changed, 284 insertions(+) create mode 100644 config/initializers/new_framework_defaults_7_1.rb 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 000000000..4ba02970b --- /dev/null +++ b/config/initializers/new_framework_defaults_7_1.rb @@ -0,0 +1,284 @@ +# 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 From b5cb4111525b369ed26e8ef019e5cb578ea6aca3 Mon Sep 17 00:00:00 2001 From: Splines Date: Sun, 7 Apr 2024 01:19:25 +0200 Subject: [PATCH 07/24] Update `listen` gem version This was done because `bin/rails app:update` failed with: ** Execute app:update:active_storage rails active_storage:update bin/rails aborted! Gem::LoadError: can't activate listen (~> 3.5), already activated listen-3.0.8. Make sure all dependencies are added to Gemfile. --- Gemfile | 4 ++-- Gemfile.lock | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Gemfile b/Gemfile index 7e980e5a8..2582e6120 100644 --- a/Gemfile +++ b/Gemfile @@ -105,9 +105,9 @@ gem "trix-rails", require: "trix" gem "webpacker", "~> 5.x" group :development, :docker_development do - # Access an interactive console on exception pages or by calling 'console' anywhere in the code. - gem "listen", ">= 3.0.5", "< 3.2" + gem "listen", "~> 3.9" gem "rails-erd" + # Access an interactive console on exception pages or by calling 'console' anywhere in the code. gem "web-console", ">= 3.3.0" # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring gem "marcel" diff --git a/Gemfile.lock b/Gemfile.lock index 91f8be12f..1d54f2f3f 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -329,9 +329,9 @@ GEM launchy (3.0.0) addressable (~> 2.8) childprocess (~> 5.0) - listen (3.0.8) - rb-fsevent (~> 0.9, >= 0.9.4) - rb-inotify (~> 0.9, >= 0.9.7) + listen (3.9.0) + rb-fsevent (~> 0.10, >= 0.10.3) + rb-inotify (~> 0.9, >= 0.9.10) loofah (2.22.0) crass (~> 1.0.2) nokogiri (>= 1.12.0) @@ -712,7 +712,7 @@ DEPENDENCIES kaminari-i18n kramdown-parser-gfm launchy - listen (>= 3.0.5, < 3.2) + listen (~> 3.9) marcel mini_magick net-smtp From 0aa94e8584e9a8792a5df76e0c05516fe45899f9 Mon Sep 17 00:00:00 2001 From: Splines Date: Sun, 7 Apr 2024 01:20:01 +0200 Subject: [PATCH 08/24] Add TODO note for upcoming serialize change --- app/models/medium.rb | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/app/models/medium.rb b/app/models/medium.rb index f0f079536..4e9c17f12 100644 --- a/app/models/medium.rb +++ b/app/models/medium.rb @@ -56,6 +56,11 @@ class Medium < ApplicationRecord has_many :assignments + # TODO Rails 7.2: specify coder: keyword to serialize objects in Rails 7.2 + # However, as found out here [1], we need to wait for a PR [2] to be merged in + # the globalize gem. + # [1] https://github.com/rails/rails/issues/50483#issuecomment-1886053412 + # [2] https://github.com/globalize/globalize/pull/811 serialize :quiz_graph, QuizGraph serialize :solution, Solution From 2988751448bd413e0087659a2c15de680fd2891f Mon Sep 17 00:00:00 2001 From: Splines Date: Sun, 7 Apr 2024 01:20:57 +0200 Subject: [PATCH 09/24] Reduce new framework defaults list --- .../new_framework_defaults_7_1.rb | 214 ++---------------- 1 file changed, 20 insertions(+), 194 deletions(-) diff --git a/config/initializers/new_framework_defaults_7_1.rb b/config/initializers/new_framework_defaults_7_1.rb index 4ba02970b..d23f804c3 100644 --- a/config/initializers/new_framework_defaults_7_1.rb +++ b/config/initializers/new_framework_defaults_7_1.rb @@ -9,34 +9,20 @@ # 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" -# } +# πŸ’₯βœ… I've removed the lines in this file where I agree with the new defaults +# or when they are not applicable to us. I've kept the lines that I'm not sure about +# or that I think we should discuss. +# TODO: We still have to activate the new defaults by setting +# `config.load_defaults` to `7.1` (!) +# ❓ Parameters Hash -- Not sure whether this affects us ### # 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 +# ❓❗ SHA-256 as new hash algorithm -- TODO: check what we should do with this ### # Active Record Encryption now uses SHA-256 as its hash digest algorithm. # @@ -48,53 +34,18 @@ #++ # 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: +# 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. +# 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_job.use_big_decimal_serializer = true +# Rails.application.config.active_record.encryption.support_sha1_for_non_deterministic_encryption +# = false +# ❓ Invalid cache expiration time, what behavior do we want? ### # Specify if an `ArgumentError` should be raised if `Rails.cache` `fetch` or # `write` are given an invalid `expires_at` or `expires_in` time. @@ -103,13 +54,7 @@ #++ # 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 - +# ❓ New default serializer ### # Specify the default serializer used by `MessageEncryptor` and `MessageVerifier` # instances. @@ -140,92 +85,15 @@ #++ # Rails.application.config.active_support.message_serializer = :json_allow_marshal +# ❓ Should discuss what we want here. +# See: https://guides.rubyonrails.org/v7.1/configuring.html#config-active-record-commit-transaction-on-non-local-return ### -# 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`. +# 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 - +# ❗ New cache format -- Add later ### # ** Please read carefully, this must be configured in config/application.rb ** # @@ -240,45 +108,3 @@ # 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 From 8d5486d6626c889a12df856d6741e0a8278ef417 Mon Sep 17 00:00:00 2001 From: Splines Date: Sun, 7 Apr 2024 01:21:18 +0200 Subject: [PATCH 10/24] Add migrations introduced by rails update task --- ..._to_active_storage_blobs.active_storage.rb | 22 +++++++++++++++ ..._storage_variant_records.active_storage.rb | 27 +++++++++++++++++++ ...e_storage_blobs_checksum.active_storage.rb | 8 ++++++ 3 files changed, 57 insertions(+) create mode 100644 db/migrate/20240406222249_add_service_name_to_active_storage_blobs.active_storage.rb create mode 100644 db/migrate/20240406222250_create_active_storage_variant_records.active_storage.rb create mode 100644 db/migrate/20240406222251_remove_not_null_on_active_storage_blobs_checksum.active_storage.rb diff --git a/db/migrate/20240406222249_add_service_name_to_active_storage_blobs.active_storage.rb b/db/migrate/20240406222249_add_service_name_to_active_storage_blobs.active_storage.rb new file mode 100644 index 000000000..a15c6ce8e --- /dev/null +++ b/db/migrate/20240406222249_add_service_name_to_active_storage_blobs.active_storage.rb @@ -0,0 +1,22 @@ +# This migration comes from active_storage (originally 20190112182829) +class AddServiceNameToActiveStorageBlobs < ActiveRecord::Migration[6.0] + def up + return unless table_exists?(:active_storage_blobs) + + unless column_exists?(:active_storage_blobs, :service_name) + add_column :active_storage_blobs, :service_name, :string + + if configured_service = ActiveStorage::Blob.service.name + ActiveStorage::Blob.unscoped.update_all(service_name: configured_service) + end + + change_column :active_storage_blobs, :service_name, :string, null: false + end + end + + def down + return unless table_exists?(:active_storage_blobs) + + remove_column :active_storage_blobs, :service_name + end +end diff --git a/db/migrate/20240406222250_create_active_storage_variant_records.active_storage.rb b/db/migrate/20240406222250_create_active_storage_variant_records.active_storage.rb new file mode 100644 index 000000000..94ac83af0 --- /dev/null +++ b/db/migrate/20240406222250_create_active_storage_variant_records.active_storage.rb @@ -0,0 +1,27 @@ +# This migration comes from active_storage (originally 20191206030411) +class CreateActiveStorageVariantRecords < ActiveRecord::Migration[6.0] + def change + return unless table_exists?(:active_storage_blobs) + + # Use Active Record's configured type for primary key + create_table :active_storage_variant_records, id: primary_key_type, if_not_exists: true do |t| + t.belongs_to :blob, null: false, index: false, type: blobs_primary_key_type + t.string :variation_digest, null: false + + t.index %i[ blob_id variation_digest ], name: "index_active_storage_variant_records_uniqueness", unique: true + t.foreign_key :active_storage_blobs, column: :blob_id + end + end + + private + def primary_key_type + config = Rails.configuration.generators + config.options[config.orm][:primary_key_type] || :primary_key + end + + def blobs_primary_key_type + pkey_name = connection.primary_key(:active_storage_blobs) + pkey_column = connection.columns(:active_storage_blobs).find { |c| c.name == pkey_name } + pkey_column.bigint? ? :bigint : pkey_column.type + end +end diff --git a/db/migrate/20240406222251_remove_not_null_on_active_storage_blobs_checksum.active_storage.rb b/db/migrate/20240406222251_remove_not_null_on_active_storage_blobs_checksum.active_storage.rb new file mode 100644 index 000000000..93c8b85ad --- /dev/null +++ b/db/migrate/20240406222251_remove_not_null_on_active_storage_blobs_checksum.active_storage.rb @@ -0,0 +1,8 @@ +# This migration comes from active_storage (originally 20211119233751) +class RemoveNotNullOnActiveStorageBlobsChecksum < ActiveRecord::Migration[6.0] + def change + return unless table_exists?(:active_storage_blobs) + + change_column_null(:active_storage_blobs, :checksum, true) + end +end From 889e2919c56ef6fb846a95db5d776a1b41ef5e86 Mon Sep 17 00:00:00 2001 From: Splines Date: Sun, 7 Apr 2024 11:15:23 +0200 Subject: [PATCH 11/24] Remove unneeded ActiveStorage migrations --- ..._to_active_storage_blobs.active_storage.rb | 22 --------------- ..._storage_variant_records.active_storage.rb | 27 ------------------- ...e_storage_blobs_checksum.active_storage.rb | 8 ------ 3 files changed, 57 deletions(-) delete mode 100644 db/migrate/20240406222249_add_service_name_to_active_storage_blobs.active_storage.rb delete mode 100644 db/migrate/20240406222250_create_active_storage_variant_records.active_storage.rb delete mode 100644 db/migrate/20240406222251_remove_not_null_on_active_storage_blobs_checksum.active_storage.rb diff --git a/db/migrate/20240406222249_add_service_name_to_active_storage_blobs.active_storage.rb b/db/migrate/20240406222249_add_service_name_to_active_storage_blobs.active_storage.rb deleted file mode 100644 index a15c6ce8e..000000000 --- a/db/migrate/20240406222249_add_service_name_to_active_storage_blobs.active_storage.rb +++ /dev/null @@ -1,22 +0,0 @@ -# This migration comes from active_storage (originally 20190112182829) -class AddServiceNameToActiveStorageBlobs < ActiveRecord::Migration[6.0] - def up - return unless table_exists?(:active_storage_blobs) - - unless column_exists?(:active_storage_blobs, :service_name) - add_column :active_storage_blobs, :service_name, :string - - if configured_service = ActiveStorage::Blob.service.name - ActiveStorage::Blob.unscoped.update_all(service_name: configured_service) - end - - change_column :active_storage_blobs, :service_name, :string, null: false - end - end - - def down - return unless table_exists?(:active_storage_blobs) - - remove_column :active_storage_blobs, :service_name - end -end diff --git a/db/migrate/20240406222250_create_active_storage_variant_records.active_storage.rb b/db/migrate/20240406222250_create_active_storage_variant_records.active_storage.rb deleted file mode 100644 index 94ac83af0..000000000 --- a/db/migrate/20240406222250_create_active_storage_variant_records.active_storage.rb +++ /dev/null @@ -1,27 +0,0 @@ -# This migration comes from active_storage (originally 20191206030411) -class CreateActiveStorageVariantRecords < ActiveRecord::Migration[6.0] - def change - return unless table_exists?(:active_storage_blobs) - - # Use Active Record's configured type for primary key - create_table :active_storage_variant_records, id: primary_key_type, if_not_exists: true do |t| - t.belongs_to :blob, null: false, index: false, type: blobs_primary_key_type - t.string :variation_digest, null: false - - t.index %i[ blob_id variation_digest ], name: "index_active_storage_variant_records_uniqueness", unique: true - t.foreign_key :active_storage_blobs, column: :blob_id - end - end - - private - def primary_key_type - config = Rails.configuration.generators - config.options[config.orm][:primary_key_type] || :primary_key - end - - def blobs_primary_key_type - pkey_name = connection.primary_key(:active_storage_blobs) - pkey_column = connection.columns(:active_storage_blobs).find { |c| c.name == pkey_name } - pkey_column.bigint? ? :bigint : pkey_column.type - end -end diff --git a/db/migrate/20240406222251_remove_not_null_on_active_storage_blobs_checksum.active_storage.rb b/db/migrate/20240406222251_remove_not_null_on_active_storage_blobs_checksum.active_storage.rb deleted file mode 100644 index 93c8b85ad..000000000 --- a/db/migrate/20240406222251_remove_not_null_on_active_storage_blobs_checksum.active_storage.rb +++ /dev/null @@ -1,8 +0,0 @@ -# This migration comes from active_storage (originally 20211119233751) -class RemoveNotNullOnActiveStorageBlobsChecksum < ActiveRecord::Migration[6.0] - def change - return unless table_exists?(:active_storage_blobs) - - change_column_null(:active_storage_blobs, :checksum, true) - end -end From 16a33b1d04cf636fab54b6336c1e6a2ef9269272 Mon Sep 17 00:00:00 2001 From: Splines Date: Sun, 7 Apr 2024 11:24:31 +0200 Subject: [PATCH 12/24] Remove defaults for sha-256 as we are unaffected --- .../new_framework_defaults_7_1.rb | 23 ------------------- 1 file changed, 23 deletions(-) diff --git a/config/initializers/new_framework_defaults_7_1.rb b/config/initializers/new_framework_defaults_7_1.rb index d23f804c3..0b4249be0 100644 --- a/config/initializers/new_framework_defaults_7_1.rb +++ b/config/initializers/new_framework_defaults_7_1.rb @@ -22,29 +22,6 @@ #++ # Rails.application.config.action_controller.allow_deprecated_parameters_hash_equality = false -# ❓❗ SHA-256 as new hash algorithm -- TODO: check what we should do with this -### -# 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 - # ❓ Invalid cache expiration time, what behavior do we want? ### # Specify if an `ArgumentError` should be raised if `Rails.cache` `fetch` or From 5d37d16a9cb3f59f7e435295e211b28b452d6a60 Mon Sep 17 00:00:00 2001 From: Splines Date: Tue, 9 Apr 2024 22:23:47 +0200 Subject: [PATCH 13/24] Use new Rails 7.1 defaults --- config/application.rb | 6 +- .../new_framework_defaults_7_1.rb | 87 ------------------- 2 files changed, 5 insertions(+), 88 deletions(-) delete mode 100644 config/initializers/new_framework_defaults_7_1.rb diff --git a/config/application.rb b/config/application.rb index d3bff2358..a61d3b198 100644 --- a/config/application.rb +++ b/config/application.rb @@ -9,7 +9,7 @@ module Mampf class Application < Rails::Application # Initialize configuration defaults for originally generated Rails version. - config.load_defaults(7.0) + config.load_defaults(7.1) config.autoloader = :zeitwerk # Autoload lib extensions path @@ -21,6 +21,10 @@ class Application < Rails::Application config.i18n.raise_on_missing_translations = true config.time_zone = "Berlin" + # Message serializing. Starting with Rails 7.2, the default is :json. + # See: https://guides.rubyonrails.org/v7.1/configuring.html#config-active-support-message-serializer + Rails.application.config.active_support.message_serializer = :json + # config.eager_load_paths << Rails.root.join("extras") # Make `form_with` generate remote forms by default. config.action_view.form_with_generates_remote_forms = true 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 0b4249be0..000000000 --- a/config/initializers/new_framework_defaults_7_1.rb +++ /dev/null @@ -1,87 +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 - -# πŸ’₯βœ… I've removed the lines in this file where I agree with the new defaults -# or when they are not applicable to us. I've kept the lines that I'm not sure about -# or that I think we should discuss. -# TODO: We still have to activate the new defaults by setting -# `config.load_defaults` to `7.1` (!) - -# ❓ Parameters Hash -- Not sure whether this affects us -### -# 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 - -# ❓ Invalid cache expiration time, what behavior do we want? -### -# 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 - -# ❓ New default serializer -### -# 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 - -# ❓ Should discuss what we want here. -# See: https://guides.rubyonrails.org/v7.1/configuring.html#config-active-record-commit-transaction-on-non-local-return -### -# 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 - -# ❗ New cache format -- Add later -### -# ** 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 From 826a800643819cbba2b6a07a0aaf57add2730610 Mon Sep 17 00:00:00 2001 From: Splines Date: Tue, 9 Apr 2024 22:26:21 +0200 Subject: [PATCH 14/24] Fix TODO rubocop warning --- app/models/medium.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/medium.rb b/app/models/medium.rb index 4e9c17f12..b3f562f69 100644 --- a/app/models/medium.rb +++ b/app/models/medium.rb @@ -56,7 +56,7 @@ class Medium < ApplicationRecord has_many :assignments - # TODO Rails 7.2: specify coder: keyword to serialize objects in Rails 7.2 + # TODO: Rails 7.2: specify coder: keyword to serialize objects in Rails 7.2 # However, as found out here [1], we need to wait for a PR [2] to be merged in # the globalize gem. # [1] https://github.com/rails/rails/issues/50483#issuecomment-1886053412 From ab6143d548dc42ccf5849603f7ce3a1899960368 Mon Sep 17 00:00:00 2001 From: Splines Date: Wed, 17 Apr 2024 01:52:29 +0200 Subject: [PATCH 15/24] Update bundler version to 2.5.9 You can do so locally via `bundle update --bundler` --- Gemfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index a4b6bdd1b..88f1ce275 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -761,4 +761,4 @@ RUBY VERSION ruby 3.1.4p223 BUNDLED WITH - 2.4.22 + 2.5.9 From 7f97403babfc14a682a1e09c7d1e98d1abaf3a01 Mon Sep 17 00:00:00 2001 From: Splines Date: Wed, 17 Apr 2024 22:59:01 +0200 Subject: [PATCH 16/24] Remove unnecessary entries in `Gemfile.lock` Performed automatically via `bundle install`. --- Gemfile.lock | 9 --------- 1 file changed, 9 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 1c38fbfe1..88f1ce275 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -517,20 +517,12 @@ GEM language_server-protocol (>= 3.17.0) parallel (~> 1.10) parser (>= 3.3.0.2) - parser (>= 3.3.0.2) rainbow (>= 2.2.2, < 4.0) regexp_parser (>= 1.8, < 3.0) rexml (>= 3.2.5, < 4.0) rubocop-ast (>= 1.31.1, < 2.0) - rubocop-ast (>= 1.31.1, < 2.0) ruby-progressbar (~> 1.7) unicode-display_width (>= 2.4.0, < 3.0) - rubocop-ast (1.31.2) - parser (>= 3.3.0.4) - rubocop-performance (1.21.0) - rubocop (>= 1.48.1, < 2.0) - rubocop-ast (>= 1.31.1, < 2.0) - rubocop-rails (2.24.1) rubocop-ast (1.31.2) parser (>= 3.3.0.4) rubocop-performance (1.21.0) @@ -541,7 +533,6 @@ GEM rack (>= 1.1) rubocop (>= 1.33.0, < 2.0) rubocop-ast (>= 1.31.1, < 2.0) - rubocop-ast (>= 1.31.1, < 2.0) ruby-graphviz (1.2.5) rexml ruby-progressbar (1.13.0) From 2b17c87804b4b4e8253af675e089a5ac55a244eb Mon Sep 17 00:00:00 2001 From: Splines Date: Mon, 22 Apr 2024 23:05:16 +0200 Subject: [PATCH 17/24] Address `Passing the coder as positional arg` deprecation This is a followup to https://github.com/rails/rails/pull/47463 --- app/models/annotation.rb | 2 +- app/models/item.rb | 2 +- app/models/lecture.rb | 2 +- app/models/medium.rb | 6 +++--- app/models/referral.rb | 4 ++-- app/models/section.rb | 2 +- app/models/tag.rb | 2 +- 7 files changed, 10 insertions(+), 10 deletions(-) diff --git a/app/models/annotation.rb b/app/models/annotation.rb index b15b36052..6ee3ec804 100644 --- a/app/models/annotation.rb +++ b/app/models/annotation.rb @@ -7,7 +7,7 @@ class Annotation < ApplicationRecord scope :commented, -> { where.not(public_comment_id: nil) } # the timestamp for the annotation position is serialized as text in the db - serialize :timestamp, TimeStamp + serialize :timestamp, coder: TimeStamp enum category: { note: 0, content: 1, mistake: 2, presentation: 3 } enum subcategory: { definition: 0, argument: 1, strategy: 2 } diff --git a/app/models/item.rb b/app/models/item.rb index c4778ca63..17f2b3cde 100644 --- a/app/models/item.rb +++ b/app/models/item.rb @@ -25,7 +25,7 @@ class Item < ApplicationRecord # an item that corresponds to a toc entry of a video has a start time # start_time is a TimeStamp object (which is serialized for the db) - serialize :start_time, TimeStamp + serialize :start_time, coder: TimeStamp # sort should be one of the following: # remark, ... , corollary - correspond to to toc entries of videos diff --git a/app/models/lecture.rb b/app/models/lecture.rb index 097bb4b52..930ad19ea 100644 --- a/app/models/lecture.rb +++ b/app/models/lecture.rb @@ -65,7 +65,7 @@ class Lecture < ApplicationRecord # a lecture has many structure_ids, referring to the ids of structures # in the erdbeere database - serialize :structure_ids, Array + serialize :structure_ids, type: Array # if the annotation button is enabled, one can add different types of links # that e.g. bring students to the helpdesk diff --git a/app/models/medium.rb b/app/models/medium.rb index b3f562f69..aaa516917 100644 --- a/app/models/medium.rb +++ b/app/models/medium.rb @@ -61,11 +61,11 @@ class Medium < ApplicationRecord # the globalize gem. # [1] https://github.com/rails/rails/issues/50483#issuecomment-1886053412 # [2] https://github.com/globalize/globalize/pull/811 - serialize :quiz_graph, QuizGraph + serialize :quiz_graph, coder: QuizGraph - serialize :solution, Solution + serialize :solution, coder: Solution - serialize :publisher, MediumPublisher + serialize :publisher, coder: MediumPublisher # include uploaders to realize video/manuscript/screenshot upload # this makes use of the shrine gem diff --git a/app/models/referral.rb b/app/models/referral.rb index 59f70ad6f..da95119cf 100644 --- a/app/models/referral.rb +++ b/app/models/referral.rb @@ -7,8 +7,8 @@ class Referral < ApplicationRecord belongs_to :medium # start_time and end_time are serialized columns - serialize :start_time, TimeStamp - serialize :end_time, TimeStamp + serialize :start_time, coder: TimeStamp + serialize :end_time, coder: TimeStamp # validations for start time and end time validate :valid_start_time diff --git a/app/models/section.rb b/app/models/section.rb index 9c54309b4..9aa5e65f8 100644 --- a/app/models/section.rb +++ b/app/models/section.rb @@ -10,7 +10,7 @@ class Section < ApplicationRecord has_many :section_tag_joins, dependent: :destroy has_many :tags, through: :section_tag_joins # the tags have an ordering (an array with their ids) - serialize :tags_order, Array + serialize :tags_order, type: Array # a section has many lessons has_many :lesson_section_joins, dependent: :destroy diff --git a/app/models/tag.rb b/app/models/tag.rb index d506e1a4f..3a463f259 100644 --- a/app/models/tag.rb +++ b/app/models/tag.rb @@ -39,7 +39,7 @@ class Tag < ApplicationRecord class_name: "Notion", inverse_of: :aliased_tag - serialize :realizations, Array + serialize :realizations, type: Array accepts_nested_attributes_for :notions, reject_if: lambda { |attributes| From 59c023e0fa4b1cbf4b19cd2709254a093bb0bb2b Mon Sep 17 00:00:00 2001 From: fosterfarrell9 <28628554+fosterfarrell9@users.noreply.github.com> Date: Tue, 23 Apr 2024 16:26:36 +0200 Subject: [PATCH 18/24] add yaml coder explicitly for serializing arrays --- app/models/lecture.rb | 2 +- app/models/section.rb | 2 +- app/models/tag.rb | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/models/lecture.rb b/app/models/lecture.rb index 930ad19ea..6ad5686b5 100644 --- a/app/models/lecture.rb +++ b/app/models/lecture.rb @@ -65,7 +65,7 @@ class Lecture < ApplicationRecord # a lecture has many structure_ids, referring to the ids of structures # in the erdbeere database - serialize :structure_ids, type: Array + serialize :structure_ids, type: Array, coder: YAML # if the annotation button is enabled, one can add different types of links # that e.g. bring students to the helpdesk diff --git a/app/models/section.rb b/app/models/section.rb index 9aa5e65f8..11c651041 100644 --- a/app/models/section.rb +++ b/app/models/section.rb @@ -10,7 +10,7 @@ class Section < ApplicationRecord has_many :section_tag_joins, dependent: :destroy has_many :tags, through: :section_tag_joins # the tags have an ordering (an array with their ids) - serialize :tags_order, type: Array + serialize :tags_order, type: Array, coder: YAML # a section has many lessons has_many :lesson_section_joins, dependent: :destroy diff --git a/app/models/tag.rb b/app/models/tag.rb index 3a463f259..dacbe1e91 100644 --- a/app/models/tag.rb +++ b/app/models/tag.rb @@ -39,7 +39,7 @@ class Tag < ApplicationRecord class_name: "Notion", inverse_of: :aliased_tag - serialize :realizations, type: Array + serialize :realizations, type: Array, coder: YAML accepts_nested_attributes_for :notions, reject_if: lambda { |attributes| From 64fba8764eba8c7030e7ed3273d8c8f068311526 Mon Sep 17 00:00:00 2001 From: fosterfarrell9 <28628554+fosterfarrell9@users.noreply.github.com> Date: Tue, 23 Apr 2024 18:08:52 +0200 Subject: [PATCH 19/24] Migrate from globalize to mobility due to serialization warnings --- Gemfile | 3 +- app/models/division.rb | 5 +- app/models/program.rb | 4 +- app/models/subject.rb | 4 +- config/initializers/mobility.rb | 116 ++++++++++++++++++++++++++++++++ config/locales/de.yml | 1 + config/locales/en.yml | 1 + 7 files changed, 122 insertions(+), 12 deletions(-) create mode 100644 config/initializers/mobility.rb diff --git a/Gemfile b/Gemfile index 94a1d26ce..da68ea8e6 100644 --- a/Gemfile +++ b/Gemfile @@ -70,8 +70,6 @@ gem "erubis" gem "exception_handler", "~> 0.8.0.0" gem "faraday", "~> 1.8" gem "fuzzy-string-match" -gem "globalize" -gem "globalize-accessors" gem "html-pipeline", "~> 2.14" gem "jquery-rails" gem "jquery-ui-rails" @@ -79,6 +77,7 @@ gem "js-routes", "1.4.9" gem "kaminari" gem "kaminari-i18n" gem "kramdown-parser-gfm" +gem "mobility" gem "net-smtp" gem "pg" gem "premailer-rails" diff --git a/app/models/division.rb b/app/models/division.rb index bab3b37ce..339fdc095 100644 --- a/app/models/division.rb +++ b/app/models/division.rb @@ -2,12 +2,9 @@ class Division < ApplicationRecord belongs_to :program has_many :division_course_joins has_many :courses, through: :division_course_joins - + extend Mobility translates :name - globalize_accessors locales: I18n.available_locales, - attributes: translated_attribute_names - def name_with_program "#{program.subject.name}:#{program.name}:#{name}" end diff --git a/app/models/program.rb b/app/models/program.rb index 1815a27a6..a981c51fb 100644 --- a/app/models/program.rb +++ b/app/models/program.rb @@ -1,10 +1,8 @@ class Program < ApplicationRecord belongs_to :subject has_many :divisions, dependent: :destroy - + extend Mobility translates :name - globalize_accessors locales: I18n.available_locales, - attributes: translated_attribute_names def name_with_subject "#{subject.name}: #{name}" diff --git a/app/models/subject.rb b/app/models/subject.rb index 110504013..a33f17226 100644 --- a/app/models/subject.rb +++ b/app/models/subject.rb @@ -1,9 +1,7 @@ class Subject < ApplicationRecord has_many :programs - + extend Mobility translates :name - globalize_accessors locales: I18n.available_locales, - attributes: translated_attribute_names def deletable? programs.none? diff --git a/config/initializers/mobility.rb b/config/initializers/mobility.rb new file mode 100644 index 000000000..4e4f17773 --- /dev/null +++ b/config/initializers/mobility.rb @@ -0,0 +1,116 @@ +Mobility.configure do + # PLUGINS + plugins do + # Backend + # + # Sets the default backend to use in models. This can be overridden in models + # by passing +backend: ...+ to +translates+. + # + # To default to a different backend globally, replace +:key_value+ by another + # backend name. + # + backend :table + + # ActiveRecord + # + # Defines ActiveRecord as ORM, and enables ActiveRecord-specific plugins. + active_record + + # Accessors + # + # Define reader and writer methods for translated attributes. Remove either + # to disable globally, or pass +reader: false+ or +writer: false+ to + # +translates+ in any translated model. + # + reader + writer + + # Backend Reader + # + # Defines reader to access the backend for any attribute, of the form + # +_backend+. + # + backend_reader + # + # Or pass an interpolation string to define a different pattern: + # backend_reader "%s_translations" + + # Query + # + # Defines a scope on the model class which allows querying on + # translated attributes. The default scope is named +i18n+, pass a different + # name as default to change the global default, or to +translates+ in any + # model to change it for that model alone. + # + query + + # Cache + # + # Comment out to disable caching reads and writes. + # + cache + + # Dirty + # + # Uncomment this line to include and enable globally: + dirty + # + # Or uncomment this line to include but disable by default, and only enable + # per model by passing +dirty: true+ to +translates+. + # dirty false + + # Fallbacks + # + # Uncomment line below to enable fallbacks, using +I18n.fallbacks+. + # fallbacks + # + # Or uncomment this line to enable fallbacks with a global default. + # fallbacks { :pt => :en } + + # Presence + # + # Converts blank strings to nil on reads and writes. Comment out to + # disable. + # + presence + + # Default + # + # Set a default translation per attributes. When enabled, passing +default: + # 'foo'+ sets a default translation string to show in case no translation is + # present. Can also be passed a proc. + # + # default 'foo' + + # Fallthrough Accessors + # + # Uses method_missing to define locale-specific accessor methods like + # +title_en+, +title_en=+, +title_fr+, +title_fr=+ for each translated + # attribute. If you know what set of locales you want to support, it's + # generally better to use Locale Accessors (or both together) since + # +method_missing+ is very slow. (You can use both fallthrough and locale + # accessor plugins together without conflict.) + # + # fallthrough_accessors + + # Locale Accessors + # + # Uses +def+ to define accessor methods for a set of locales. By default uses + # +I18n.available_locales+, but you can pass the set of locales with + # +translates+ and/or set a global default here. + # + locale_accessors + # + # Or define specific defaults by uncommenting line below + # locale_accessors [:en, :ja] + + # Attribute Methods + # + # Adds translated attributes to +attributes+ hash, and defines methods + # +translated_attributes+ and +untranslated_attributes+ which return hashes + # with translated and untranslated attributes, respectively. Be aware that + # this plugin can create conflicts with other gems. + # + # attribute_methods + end +end diff --git a/config/locales/de.yml b/config/locales/de.yml index ab65ef312..3fd09b2cc 100644 --- a/config/locales/de.yml +++ b/config/locales/de.yml @@ -2674,6 +2674,7 @@ de: resources: Ressourcen blog: Blog guided_tour: gefΓΌhrter Tour + researchgate: Researchgate math: number: 'Zahl' complex_number: 'komplexe Zahl' diff --git a/config/locales/en.yml b/config/locales/en.yml index a26f1bc6f..05c1441ac 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -2514,6 +2514,7 @@ en: resources: resources blog: Blog guided_tour: guided tour + researchgate: Researchgate math: number: 'number' complex_number: 'complex number' From d6951886918e48da06e4f3416110775c1004d703 Mon Sep 17 00:00:00 2001 From: Splines Date: Wed, 24 Apr 2024 09:33:34 +0200 Subject: [PATCH 20/24] Update gem lockfile to include `mobility` `bundle install` also removed globalize automatically for us. --- Gemfile.lock | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 88f1ce275..8330339dc 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -260,12 +260,6 @@ GEM RubyInline (>= 3.8.6) globalid (1.2.1) activesupport (>= 6.1) - globalize (6.3.0) - activemodel (>= 4.2, < 7.2) - activerecord (>= 4.2, < 7.2) - request_store (~> 1.0) - globalize-accessors (0.3.0) - globalize (>= 5.0.0) hashery (2.1.2) highline (2.1.0) html-pipeline (2.14.3) @@ -347,6 +341,9 @@ GEM mini_magick (4.12.0) mini_mime (1.1.5) minitest (5.22.3) + mobility (1.2.9) + i18n (>= 0.6.10, < 2) + request_store (~> 1.0) msgpack (1.7.2) multi_json (1.15.0) multipart-post (2.4.0) @@ -699,8 +696,6 @@ DEPENDENCIES fastimage filesize fuzzy-string-match - globalize - globalize-accessors html-pipeline (~> 2.14) image_processing jbuilder @@ -714,6 +709,7 @@ DEPENDENCIES listen (~> 3.9) marcel mini_magick + mobility net-smtp pdf-reader pg From f486935776582160a036cb4f84c1c142ec5f8c20 Mon Sep 17 00:00:00 2001 From: Splines Date: Wed, 24 Apr 2024 10:12:50 +0200 Subject: [PATCH 21/24] Add `I18nLocaleAccessors` as replacement for `globalize_attribute_names` --- app/controllers/divisions_controller.rb | 2 +- app/controllers/programs_controller.rb | 2 +- app/controllers/subjects_controller.rb | 2 +- app/models/division.rb | 1 + app/models/program.rb | 1 + app/models/subject.rb | 1 + config/initializers/mobility.rb | 10 ++++++++++ 7 files changed, 16 insertions(+), 3 deletions(-) diff --git a/app/controllers/divisions_controller.rb b/app/controllers/divisions_controller.rb index dc2195d75..03de7eb0c 100644 --- a/app/controllers/divisions_controller.rb +++ b/app/controllers/divisions_controller.rb @@ -43,6 +43,6 @@ def set_division end def division_params - params.require(:division).permit(*Division.globalize_attribute_names) + params.require(:division).permit(*Division.locale_accessor_names) end end diff --git a/app/controllers/programs_controller.rb b/app/controllers/programs_controller.rb index 28e9aab55..836423078 100644 --- a/app/controllers/programs_controller.rb +++ b/app/controllers/programs_controller.rb @@ -43,6 +43,6 @@ def set_program end def program_params - params.require(:program).permit(*Program.globalize_attribute_names) + params.require(:program).permit(*Program.locale_accessor_names) end end diff --git a/app/controllers/subjects_controller.rb b/app/controllers/subjects_controller.rb index 29fa26cf4..2e9d0c439 100644 --- a/app/controllers/subjects_controller.rb +++ b/app/controllers/subjects_controller.rb @@ -42,6 +42,6 @@ def set_subject end def subject_params - params.require(:subject).permit(*Subject.globalize_attribute_names) + params.require(:subject).permit(*Subject.locale_accessor_names) end end diff --git a/app/models/division.rb b/app/models/division.rb index 339fdc095..995a9af0d 100644 --- a/app/models/division.rb +++ b/app/models/division.rb @@ -3,6 +3,7 @@ class Division < ApplicationRecord has_many :division_course_joins has_many :courses, through: :division_course_joins extend Mobility + extend I18nLocaleAccessors translates :name def name_with_program diff --git a/app/models/program.rb b/app/models/program.rb index a981c51fb..2502b5650 100644 --- a/app/models/program.rb +++ b/app/models/program.rb @@ -2,6 +2,7 @@ class Program < ApplicationRecord belongs_to :subject has_many :divisions, dependent: :destroy extend Mobility + extend I18nLocaleAccessors translates :name def name_with_subject diff --git a/app/models/subject.rb b/app/models/subject.rb index a33f17226..98f432f18 100644 --- a/app/models/subject.rb +++ b/app/models/subject.rb @@ -1,6 +1,7 @@ class Subject < ApplicationRecord has_many :programs extend Mobility + extend I18nLocaleAccessors translates :name def deletable? diff --git a/config/initializers/mobility.rb b/config/initializers/mobility.rb index 4e4f17773..a6dcd9280 100644 --- a/config/initializers/mobility.rb +++ b/config/initializers/mobility.rb @@ -114,3 +114,13 @@ # attribute_methods end end + +module I18nLocaleAccessors + def locale_accessor_names + mobility_attributes.flat_map do |name| + Mobility.available_locales.map do |locale| + "#{name}_#{Mobility.normalize_locale(locale)}" + end + end + end +end From fe6519281b962e747078441bc3ed1b4ae7b168e5 Mon Sep 17 00:00:00 2001 From: Splines Date: Wed, 24 Apr 2024 10:13:00 +0200 Subject: [PATCH 22/24] Remove obsolete comment regarding `globalize` --- app/models/medium.rb | 5 ----- 1 file changed, 5 deletions(-) diff --git a/app/models/medium.rb b/app/models/medium.rb index aaa516917..fe7b8e191 100644 --- a/app/models/medium.rb +++ b/app/models/medium.rb @@ -56,11 +56,6 @@ class Medium < ApplicationRecord has_many :assignments - # TODO: Rails 7.2: specify coder: keyword to serialize objects in Rails 7.2 - # However, as found out here [1], we need to wait for a PR [2] to be merged in - # the globalize gem. - # [1] https://github.com/rails/rails/issues/50483#issuecomment-1886053412 - # [2] https://github.com/globalize/globalize/pull/811 serialize :quiz_graph, coder: QuizGraph serialize :solution, coder: Solution From 4b8ad5955829798150acc49bdd8e20157e218d65 Mon Sep 17 00:00:00 2001 From: Splines Date: Wed, 24 Apr 2024 10:23:56 +0200 Subject: [PATCH 23/24] Fix Rails `secrets` deprecation warning (Devise) This is due to https://github.com/heartcombo/devise/issues/5644. --- config/initializers/devise.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/config/initializers/devise.rb b/config/initializers/devise.rb index d900ea888..4c676dc73 100644 --- a/config/initializers/devise.rb +++ b/config/initializers/devise.rb @@ -6,6 +6,7 @@ # confirmation, reset password and unlock tokens in the database. # Devise will use the `secret_key_base` as its `secret_key` # by default. You can change it below and use your own secret key. + config.secret_key = Rails.application.secret_key_base # ==> Mailer Configuration # Configure the e-mail address which will be shown in Devise::Mailer, From 652f8be9a0fff4200b68caad291b3b4e23d1ba73 Mon Sep 17 00:00:00 2001 From: Splines Date: Wed, 24 Apr 2024 10:28:09 +0200 Subject: [PATCH 24/24] Use `install_folder` in cypress on rails `cypress_folder` is deprecated as config option --- config/initializers/cypress_on_rails.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/config/initializers/cypress_on_rails.rb b/config/initializers/cypress_on_rails.rb index 223ed8e30..a9839d66b 100644 --- a/config/initializers/cypress_on_rails.rb +++ b/config/initializers/cypress_on_rails.rb @@ -1,6 +1,7 @@ if defined?(CypressOnRails) CypressOnRails.configure do |c| - c.cypress_folder = File.expand_path("#{__dir__}/../../spec/cypress") + c.install_folder = File.expand_path("#{__dir__}/../../spec/cypress") + # WARNING!! CypressOnRails can execute arbitrary ruby code # please use with extra caution if enabling on hosted servers # or starting your local server on 0.0.0.0