diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a9164f85ce..b89359d9db 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -53,7 +53,6 @@ jobs: fail-fast: false matrix: include: - - { ruby: '3.1', postgres: 13.5 } - { ruby: '3.2', postgres: 13.5 } services: diff --git a/.github/workflows/rubocop.yml b/.github/workflows/rubocop.yml index 3a0c56f579..44e51ed7b9 100644 --- a/.github/workflows/rubocop.yml +++ b/.github/workflows/rubocop.yml @@ -18,7 +18,7 @@ jobs: - name: Install Ruby uses: ruby/setup-ruby@v1 with: - ruby-version: 3.1 + ruby-version: 3.2 - name: Run RuboCop linter uses: reviewdog/action-rubocop@v2.14.0 diff --git a/.ruby-style.yml b/.ruby-style.yml index 314ba67d63..602b47d116 100644 --- a/.ruby-style.yml +++ b/.ruby-style.yml @@ -5,7 +5,7 @@ require: - "./lib/custom_cops/empty_lines_around_rescued_exceptions.rb" AllCops: - TargetRubyVersion: 3.1 + TargetRubyVersion: 3.2 RubyInterpreters: - ruby - rake @@ -449,6 +449,9 @@ Lint/ConstantDefinitionInBlock: Lint/ConstantOverwrittenInRescue: Enabled: false +Lint/ConstantReassignment: + Enabled: false + Lint/ConstantResolution: Enabled: false @@ -746,6 +749,9 @@ Lint/ShadowedException: Lint/ShadowingOuterLocalVariable: Enabled: true +Lint/SharedMutableDefault: + Enabled: false + Lint/StructNewOverride: Enabled: false @@ -1847,6 +1853,9 @@ Style/InvertibleUnlessCondition: Style/IpAddresses: Enabled: false +Style/ItAssignment: + Enabled: false + Style/KeywordArgumentsMerging: Enabled: false diff --git a/.ruby-version.example b/.ruby-version.example index 9cec7165ab..34cde5690e 100644 --- a/.ruby-version.example +++ b/.ruby-version.example @@ -1 +1 @@ -3.1.6 +3.2.6 diff --git a/Gemfile b/Gemfile index efb78cd062..d02b160685 100644 --- a/Gemfile +++ b/Gemfile @@ -79,7 +79,7 @@ # the new version. It is always preferable to upgrade our code. source 'https://rubygems.org' -gem 'rails', '~> 7.0.8' +gem 'rails', '~> 7.1.5.1' gem 'pg', '~> 1.5.9' @@ -88,17 +88,18 @@ gem 'addressable', '~> 2.8.7' gem 'acts_as_versioned', git: 'https://github.com/mysociety/acts_as_versioned.git', ref: '13e928b' gem 'active_model_otp' -gem 'activejob-uniqueness', '~> 0.2.5' +gem 'activejob-uniqueness', '~> 0.4.0' gem 'bcrypt', '~> 3.1.20' gem 'cancancan', '~> 3.6.1' gem 'charlock_holmes', '~> 0.7.9' gem 'dalli', '~> 3.2.8' -gem 'exception_notification', '~> 4.5.0' +gem 'exception_notification', git: 'https://github.com/smartinez87/exception_notification.git', branch: 'master' gem 'fancybox-rails', '~> 0.3.0' gem 'friendly_id', '~> 5.5.1' gem 'gnuplot', '~> 2.6.0' gem 'htmlentities', '~> 4.3.0' gem 'icalendar', '~> 2.10.3' +gem 'image_processing', '~> 1.13' gem 'jquery-rails', '~> 4.6.0' gem 'jquery-ui-rails', '~> 6.0.0' gem 'json', '~> 2.9.1' @@ -111,10 +112,9 @@ gem 'nokogiri', '~> 1.18.1' gem 'open4', '~> 1.3.0' gem 'puma', '~> 6.5.0' gem 'rack', '~> 2.2.10' -gem 'rack-utf8_sanitizer', '~> 1.9.1' +gem 'rack-utf8_sanitizer', '~> 1.10.1' gem 'recaptcha', '~> 5.18.0', require: 'recaptcha/rails' gem 'matrix', '~> 0.4.2' -gem 'mini_magick', '~> 4.13.1' gem 'net-protocol', '~> 0.1.3' gem 'redcarpet', '~> 3.6.0' gem 'redis', '~> 4.8.1' @@ -125,7 +125,7 @@ gem 'secure_headers', '~> 7.0.0' gem 'sidekiq', '~> 6.5.12' gem 'sidekiq-limit_fetch', '~> 4.4.1' gem 'statistics2', '~> 0.54' -gem 'strip_attributes', git: 'https://github.com/mysociety/strip_attributes.git', branch: 'globalize3-rails7' +gem 'strip_attributes', git: 'https://github.com/mysociety/strip_attributes.git', branch: 'globalize3-rails8' gem 'stripe', '~> 11.7.0' gem 'syck', '~> 1.4.1', require: false gem 'syslog_protocol', '~> 0.9.0' @@ -146,7 +146,7 @@ gem 'gender_detector', '~> 2.0.0' gem 'i18n', '~> 1.14.6' gem 'rails-i18n', '~> 7.0.10' gem 'gettext_i18n_rails', '~> 1.13.0' - gem 'fast_gettext', '~> 3.1.0' + gem 'fast_gettext', '~> 4.0.0' gem 'gettext', '~> 3.5.0' gem 'globalize', '~> 7.0.0' gem 'locale', '~> 2.1.4' @@ -204,7 +204,7 @@ group :development do gem 'net-ssh-gateway', '>= 1.1.0', '< 3.0.0' gem 'launchy', '< 3.1.0' gem 'web-console', '>= 3.3.0' - gem 'rubocop', '~> 1.69.2', require: false + gem 'rubocop', '~> 1.70.0', require: false gem 'rubocop-performance', require: false gem 'rubocop-rails', require: false end diff --git a/Gemfile.lock b/Gemfile.lock index 92e209434d..3336e03989 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -17,20 +17,29 @@ GIT GIT remote: https://github.com/mysociety/strip_attributes.git - revision: 842a889258a897692296dff8445bb9dc12e676f8 - branch: globalize3-rails7 + revision: 75f12bd5c68d4099142cb659a176748df0847488 + branch: globalize3-rails8 specs: - strip_attributes (1.12.0) - activemodel (>= 3.0, < 8.0) + strip_attributes (1.14.1) + activemodel (>= 3.0, < 9.0) + +GIT + remote: https://github.com/smartinez87/exception_notification.git + revision: 60e158888bbff96f7a9ae00ae97305cdd33726e9 + branch: master + specs: + exception_notification (4.5.0) + actionmailer (>= 5.2, < 9) + activesupport (>= 5.2, < 9) PATH remote: gems/alaveteli_features specs: alaveteli_features (0.0.1) - flipper (~> 0.10) - flipper-active_record (~> 0.10) + flipper (~> 1.3.2) + flipper-active_record (~> 1.3.2) mime-types (< 4.0.0) - rails (>= 7.0.4, < 8.1.0) + rails (>= 7.1.5.1, < 7.2.0) PATH remote: gems/excel_analyzer @@ -45,76 +54,88 @@ PATH GEM remote: https://rubygems.org/ specs: - actioncable (7.0.8.7) - actionpack (= 7.0.8.7) - activesupport (= 7.0.8.7) + actioncable (7.1.5.1) + actionpack (= 7.1.5.1) + activesupport (= 7.1.5.1) nio4r (~> 2.0) websocket-driver (>= 0.6.1) - actionmailbox (7.0.8.7) - actionpack (= 7.0.8.7) - activejob (= 7.0.8.7) - activerecord (= 7.0.8.7) - activestorage (= 7.0.8.7) - activesupport (= 7.0.8.7) + zeitwerk (~> 2.6) + actionmailbox (7.1.5.1) + actionpack (= 7.1.5.1) + activejob (= 7.1.5.1) + activerecord (= 7.1.5.1) + activestorage (= 7.1.5.1) + activesupport (= 7.1.5.1) mail (>= 2.7.1) net-imap net-pop net-smtp - actionmailer (7.0.8.7) - actionpack (= 7.0.8.7) - actionview (= 7.0.8.7) - activejob (= 7.0.8.7) - activesupport (= 7.0.8.7) + actionmailer (7.1.5.1) + actionpack (= 7.1.5.1) + actionview (= 7.1.5.1) + activejob (= 7.1.5.1) + activesupport (= 7.1.5.1) mail (~> 2.5, >= 2.5.4) net-imap net-pop net-smtp - rails-dom-testing (~> 2.0) - actionpack (7.0.8.7) - actionview (= 7.0.8.7) - activesupport (= 7.0.8.7) - rack (~> 2.0, >= 2.2.4) + rails-dom-testing (~> 2.2) + actionpack (7.1.5.1) + actionview (= 7.1.5.1) + activesupport (= 7.1.5.1) + nokogiri (>= 1.8.5) + racc + rack (>= 2.2.4) + rack-session (>= 1.0.1) rack-test (>= 0.6.3) - rails-dom-testing (~> 2.0) - rails-html-sanitizer (~> 1.0, >= 1.2.0) - actiontext (7.0.8.7) - actionpack (= 7.0.8.7) - activerecord (= 7.0.8.7) - activestorage (= 7.0.8.7) - activesupport (= 7.0.8.7) + rails-dom-testing (~> 2.2) + rails-html-sanitizer (~> 1.6) + actiontext (7.1.5.1) + actionpack (= 7.1.5.1) + activerecord (= 7.1.5.1) + activestorage (= 7.1.5.1) + activesupport (= 7.1.5.1) globalid (>= 0.6.0) nokogiri (>= 1.8.5) - actionview (7.0.8.7) - activesupport (= 7.0.8.7) + actionview (7.1.5.1) + activesupport (= 7.1.5.1) builder (~> 3.1) - erubi (~> 1.4) - rails-dom-testing (~> 2.0) - rails-html-sanitizer (~> 1.1, >= 1.2.0) + erubi (~> 1.11) + rails-dom-testing (~> 2.2) + rails-html-sanitizer (~> 1.6) active_model_otp (2.3.4) activemodel rotp (~> 6.3.0) - activejob (7.0.8.7) - activesupport (= 7.0.8.7) + activejob (7.1.5.1) + activesupport (= 7.1.5.1) globalid (>= 0.3.6) - activejob-uniqueness (0.2.5) - activejob (>= 4.2, < 7.1) - redlock (>= 1.2, < 2) - activemodel (7.0.8.7) - activesupport (= 7.0.8.7) - activerecord (7.0.8.7) - activemodel (= 7.0.8.7) - activesupport (= 7.0.8.7) - activestorage (7.0.8.7) - actionpack (= 7.0.8.7) - activejob (= 7.0.8.7) - activerecord (= 7.0.8.7) - activesupport (= 7.0.8.7) + activejob-uniqueness (0.4.0) + activejob (>= 4.2, < 8.1) + redlock (>= 2.0, < 3) + activemodel (7.1.5.1) + activesupport (= 7.1.5.1) + activerecord (7.1.5.1) + activemodel (= 7.1.5.1) + activesupport (= 7.1.5.1) + timeout (>= 0.4.0) + activestorage (7.1.5.1) + actionpack (= 7.1.5.1) + activejob (= 7.1.5.1) + activerecord (= 7.1.5.1) + activesupport (= 7.1.5.1) marcel (~> 1.0) - mini_mime (>= 1.1.0) - activesupport (7.0.8.7) + activesupport (7.1.5.1) + base64 + benchmark (>= 0.3) + bigdecimal concurrent-ruby (~> 1.0, >= 1.0.2) + connection_pool (>= 2.2.5) + drb i18n (>= 1.6, < 2) + logger (>= 1.4.2) minitest (>= 5.1) + mutex_m + securerandom (>= 0.3) tzinfo (~> 2.0) addressable (2.8.7) public_suffix (>= 2.0.2, < 7.0) @@ -140,6 +161,7 @@ GEM aws-eventstream (~> 1, >= 1.0.2) base64 (0.2.0) bcrypt (3.1.20) + benchmark (0.4.0) bigdecimal (3.1.8) bindex (0.8.1) bootstrap-sass (2.3.2.2) @@ -181,10 +203,8 @@ GEM digest-crc (0.6.5) rake (>= 12.0.0, < 14.0.0) docile (1.4.0) + drb (2.2.1) erubi (1.13.1) - exception_notification (4.5.0) - actionmailer (>= 5.2, < 8) - activesupport (>= 5.2, < 8) execjs (2.9.1) factory_bot (6.5.0) activesupport (>= 5.0.0) @@ -199,14 +219,19 @@ GEM logger faraday-net_http (3.4.0) net-http (>= 0.5.0) - fast_gettext (3.1.0) + fast_gettext (4.0.0) prime + ffi (1.17.1) + ffi (1.17.1-aarch64-linux-gnu) + ffi (1.17.1-arm64-darwin) + ffi (1.17.1-x86_64-darwin) + ffi (1.17.1-x86_64-linux-gnu) fivemat (1.3.7) - flipper (0.28.3) + flipper (1.3.2) concurrent-ruby (< 2) - flipper-active_record (0.28.3) - activerecord (>= 4.2, < 8) - flipper (~> 0.28.3) + flipper-active_record (1.3.2) + activerecord (>= 4.2, < 9) + flipper (~> 1.3.2) forwardable (1.3.3) friendly_id (5.5.1) activerecord (>= 4.0.0) @@ -275,10 +300,17 @@ GEM ice_cube (~> 0.16) ostruct ice_cube (0.17.0) + image_processing (1.13.0) + mini_magick (>= 4.9.5, < 5) + ruby-vips (>= 2.0.17, < 3) importmap-rails (2.1.0) actionpack (>= 6.0.0) activesupport (>= 6.0.0) railties (>= 6.0.0) + io-console (0.8.0) + irb (1.14.3) + rdoc (>= 4.0.0) + reline (>= 0.4.2) iso_country_codes (0.7.8) jmespath (1.6.2) jquery-rails (4.6.0) @@ -318,7 +350,7 @@ GEM logger mime-types-data (~> 3.2015) mime-types-data (3.2024.1001) - mini_magick (4.13.1) + mini_magick (4.13.2) mini_mime (1.1.5) mini_portile2 (2.8.8) mini_racer (0.16.0) @@ -375,29 +407,37 @@ GEM pry (0.15.2) coderay (~> 1.1) method_source (~> 1.0) + psych (5.2.2) + date + stringio public_suffix (6.0.1) puma (6.5.0) nio4r (~> 2.0) racc (1.8.1) rack (2.2.10) + rack-session (1.0.2) + rack (< 3) rack-test (2.1.0) rack (>= 1.3) - rack-utf8_sanitizer (1.9.1) + rack-utf8_sanitizer (1.10.1) rack (>= 1.0, < 4.0) - rails (7.0.8.7) - actioncable (= 7.0.8.7) - actionmailbox (= 7.0.8.7) - actionmailer (= 7.0.8.7) - actionpack (= 7.0.8.7) - actiontext (= 7.0.8.7) - actionview (= 7.0.8.7) - activejob (= 7.0.8.7) - activemodel (= 7.0.8.7) - activerecord (= 7.0.8.7) - activestorage (= 7.0.8.7) - activesupport (= 7.0.8.7) + rackup (1.0.1) + rack (< 3) + webrick + rails (7.1.5.1) + actioncable (= 7.1.5.1) + actionmailbox (= 7.1.5.1) + actionmailer (= 7.1.5.1) + actionpack (= 7.1.5.1) + actiontext (= 7.1.5.1) + actionview (= 7.1.5.1) + activejob (= 7.1.5.1) + activemodel (= 7.1.5.1) + activerecord (= 7.1.5.1) + activestorage (= 7.1.5.1) + activesupport (= 7.1.5.1) bundler (>= 1.15.0) - railties (= 7.0.8.7) + railties (= 7.1.5.1) rails-controller-testing (1.0.5) actionpack (>= 5.0.1.rc1) actionview (>= 5.0.1.rc1) @@ -412,21 +452,28 @@ GEM rails-i18n (7.0.10) i18n (>= 0.7, < 2) railties (>= 6.0.0, < 8) - railties (7.0.8.7) - actionpack (= 7.0.8.7) - activesupport (= 7.0.8.7) - method_source + railties (7.1.5.1) + actionpack (= 7.1.5.1) + activesupport (= 7.1.5.1) + irb + rackup (>= 1.0.0) rake (>= 12.2) - thor (~> 1.0) - zeitwerk (~> 2.5) + thor (~> 1.0, >= 1.2.2) + zeitwerk (~> 2.6) rainbow (3.1.1) rake (13.2.1) + rdoc (6.10.0) + psych (>= 4.0.0) recaptcha (5.18.0) redcarpet (3.6.0) redis (4.8.1) - redlock (1.3.2) - redis (>= 3.0.0, < 6.0) + redis-client (0.23.0) + connection_pool + redlock (2.0.6) + redis-client (>= 0.14.1, < 1.0.0) regexp_parser (2.10.0) + reline (0.6.0) + io-console (~> 0.5) representable (3.2.0) declarative (< 0.1.0) trailblazer-option (>= 0.1.1, < 0.2.0) @@ -458,7 +505,7 @@ GEM rspec-mocks (~> 3.13) rspec-support (~> 3.13) rspec-support (3.13.1) - rubocop (1.69.2) + rubocop (1.70.0) json (~> 2.3) language_server-protocol (>= 3.17.0) parallel (~> 1.10) @@ -480,6 +527,9 @@ GEM rubocop-ast (>= 1.31.1, < 2.0) ruby-ole (1.2.12.1) ruby-progressbar (1.13.0) + ruby-vips (2.2.2) + ffi (~> 1.12) + logger rubyXL (3.4.33) nokogiri (>= 1.10.8) rubyzip (>= 1.3.0) @@ -492,6 +542,7 @@ GEM sprockets-rails (>= 2.0, < 4.0) tilt (>= 1.1, < 3) secure_headers (7.0.0) + securerandom (0.4.1) sidekiq (6.5.12) connection_pool (>= 2.2.5, < 3) rack (~> 2.0) @@ -522,6 +573,7 @@ GEM statistics2 (0.54) stimulus-rails (1.3.4) railties (>= 6.0.0) + stringio (3.1.2) stripe (11.7.0) stripe-ruby-mock (4.0.0) dante (>= 0.2.0) @@ -543,7 +595,7 @@ GEM uglifier (4.2.1) execjs (>= 0.3.0, < 3) unicode (0.4.4.5) - unicode-display_width (3.1.2) + unicode-display_width (3.1.3) unicode-emoji (~> 4.0, >= 4.0.4) unicode-emoji (4.0.4) unidecoder (1.1.2) @@ -559,7 +611,9 @@ GEM addressable (>= 2.8.0) crack (>= 0.3.2) hashdiff (>= 0.4.0, < 2.0.0) - websocket-driver (0.7.6) + webrick (1.9.1) + websocket-driver (0.7.7) + base64 websocket-extensions (>= 0.1.0) websocket-extensions (0.1.5) will_paginate (4.0.1) @@ -582,7 +636,7 @@ PLATFORMS DEPENDENCIES active_model_otp - activejob-uniqueness (~> 0.2.5) + activejob-uniqueness (~> 0.4.0) acts_as_versioned! addressable (~> 2.8.7) alaveteli_features! @@ -597,10 +651,10 @@ DEPENDENCIES charlock_holmes (~> 0.7.9) dalli (~> 3.2.8) excel_analyzer! - exception_notification (~> 4.5.0) + exception_notification! factory_bot_rails (~> 6.4.4) fancybox-rails (~> 0.3.0) - fast_gettext (~> 3.1.0) + fast_gettext (~> 4.0.0) fivemat (~> 1.3.7) friendly_id (~> 5.5.1) gender_detector (~> 2.0.0) @@ -613,6 +667,7 @@ DEPENDENCIES htmlentities (~> 4.3.0) i18n (~> 1.14.6) icalendar (~> 2.10.3) + image_processing (~> 1.13) importmap-rails (~> 2.1.0) iso_country_codes (~> 0.7.8) jquery-rails (~> 4.6.0) @@ -625,7 +680,6 @@ DEPENDENCIES matrix (~> 0.4.2) maxmind-db (~> 1.2.0) mime-types (< 4.0.0) - mini_magick (~> 4.13.1) mini_racer (~> 0.16.0) money (~> 6.19.0) net-protocol (~> 0.1.3) @@ -638,8 +692,8 @@ DEPENDENCIES pry (~> 0.15.2) puma (~> 6.5.0) rack (~> 2.2.10) - rack-utf8_sanitizer (~> 1.9.1) - rails (~> 7.0.8) + rack-utf8_sanitizer (~> 1.10.1) + rails (~> 7.1.5.1) rails-controller-testing rails-i18n (~> 7.0.10) recaptcha (~> 5.18.0) @@ -648,7 +702,7 @@ DEPENDENCIES rolify (~> 6.0.1) rspec-activemodel-mocks (~> 1.2.1) rspec-rails (~> 7.1.0) - rubocop (~> 1.69.2) + rubocop (~> 1.70.0) rubocop-performance rubocop-rails ruby-msg (~> 1.5.0)! diff --git a/README.md b/README.md index 71b60698ec..71c6dea15a 100644 --- a/README.md +++ b/README.md @@ -37,10 +37,9 @@ see [the project website](http://alaveteli.org) for instructions on installing A Every Alaveteli commit is tested by GitHub Actions on the [following Ruby platforms](https://github.com/mysociety/alaveteli/blob/develop/.github/workflows/ci.yml#L27-L29) -* ruby-3.1 * ruby-3.2 -If you use a ruby version management tool (such as RVM or .rbenv) and want to use the default development version used by the Alaveteli team (currently 3.1.6), you can create a `.ruby-version` symlink with a target of `.ruby-version.example` to switch to that automatically in the project directory. +If you use a ruby version management tool (such as RVM or .rbenv) and want to use the default development version used by the Alaveteli team (currently 3.2.6), you can create a `.ruby-version` symlink with a target of `.ruby-version.example` to switch to that automatically in the project directory. ## How to contribute diff --git a/app/controllers/comment_controller.rb b/app/controllers/comment_controller.rb index 1d96061325..2e8ea2f79d 100644 --- a/app/controllers/comment_controller.rb +++ b/app/controllers/comment_controller.rb @@ -54,7 +54,6 @@ def new flash[:notice] = _("Thank you for making an annotation!") if params[:subscribe_to_request] - @track_thing = TrackThing.create_track_for_request(@info_request) @existing_track = TrackThing.find_existing(@user, @track_thing) if @user && @info_request.user == @user # don't subscribe to own request! diff --git a/app/controllers/refusal_advice_controller.rb b/app/controllers/refusal_advice_controller.rb index a8b99c6a14..753127f5a7 100644 --- a/app/controllers/refusal_advice_controller.rb +++ b/app/controllers/refusal_advice_controller.rb @@ -85,15 +85,11 @@ def refusal_advice_params end def parsed_refusal_advice_params - parsed_params = refusal_advice_params.merge( + refusal_advice_params.merge( actions: refusal_advice_params.fetch(:actions). each_pair do |_, suggestions| suggestions.transform_values! { |v| v == 'true' } end ).to_h - - return parsed_params.deep_symbolize_keys if RUBY_VERSION < '3.0' - - parsed_params end end diff --git a/app/controllers/user_controller.rb b/app/controllers/user_controller.rb index 3dd0977586..4590b81f47 100644 --- a/app/controllers/user_controller.rb +++ b/app/controllers/user_controller.rb @@ -25,7 +25,7 @@ class UserController < ApplicationController # tries to sign in or sign up. There's little CSRF potential here as # these actions only sign in or up users with valid credentials. The # user_id in the session is not expected, and gives no extra privilege - skip_before_action :verify_authenticity_token, only: [:signin, :signup] + skip_before_action :verify_authenticity_token, only: [:signup] # Show page about a user def show diff --git a/app/models/alaveteli_pro/draft_info_request_batch.rb b/app/models/alaveteli_pro/draft_info_request_batch.rb index 9b5f7c7e03..3043b3b1a9 100644 --- a/app/models/alaveteli_pro/draft_info_request_batch.rb +++ b/app/models/alaveteli_pro/draft_info_request_batch.rb @@ -25,8 +25,6 @@ class AlaveteliPro::DraftInfoRequestBatch < ApplicationRecord end }, inverse_of: :draft_info_request_batches - validates_presence_of :user - after_initialize :set_default_body strip_attributes only: %i[embargo_duration] diff --git a/app/models/alaveteli_pro/embargo.rb b/app/models/alaveteli_pro/embargo.rb index 864414b343..ff064ed6e8 100644 --- a/app/models/alaveteli_pro/embargo.rb +++ b/app/models/alaveteli_pro/embargo.rb @@ -22,7 +22,6 @@ class Embargo < ApplicationRecord inverse_of: :embargoes, through: :info_request - validates_presence_of :info_request validates_presence_of :publish_at validates_inclusion_of :embargo_duration, in: ->(e) { e.allowed_durations }, diff --git a/app/models/alaveteli_pro/embargo_extension.rb b/app/models/alaveteli_pro/embargo_extension.rb index bff61e5f15..9220d60718 100644 --- a/app/models/alaveteli_pro/embargo_extension.rb +++ b/app/models/alaveteli_pro/embargo_extension.rb @@ -14,7 +14,6 @@ module AlaveteliPro class EmbargoExtension < ApplicationRecord belongs_to :embargo, inverse_of: :embargo_extensions - validates_presence_of :embargo validates_presence_of :extension_duration validates_inclusion_of :extension_duration, in: lambda { |_e| AlaveteliPro::Embargo.new.allowed_durations } diff --git a/app/models/alaveteli_pro/request_summary.rb b/app/models/alaveteli_pro/request_summary.rb index 1ac859fe76..7855d58736 100644 --- a/app/models/alaveteli_pro/request_summary.rb +++ b/app/models/alaveteli_pro/request_summary.rb @@ -19,13 +19,13 @@ class AlaveteliPro::RequestSummary < ApplicationRecord belongs_to :summarisable, polymorphic: true belongs_to :user, - inverse_of: :request_summaries + inverse_of: :request_summaries, + optional: true has_and_belongs_to_many :request_summary_categories, class_name: "AlaveteliPro::RequestSummaryCategory", inverse_of: :request_summaries - validates_presence_of :summarisable, - :request_created_at, + validates_presence_of :request_created_at, :request_updated_at validates_uniqueness_of :summarisable_id, scope: :summarisable_type diff --git a/app/models/announcement.rb b/app/models/announcement.rb index fc1411550a..9601ec77e1 100644 --- a/app/models/announcement.rb +++ b/app/models/announcement.rb @@ -74,7 +74,7 @@ class Announcement < ApplicationRecord end } - validates :content, :user, + validates :content, presence: true validates :visibility, presence: true, diff --git a/app/models/announcement_dismissal.rb b/app/models/announcement_dismissal.rb index 51599ead58..aa158646b8 100644 --- a/app/models/announcement_dismissal.rb +++ b/app/models/announcement_dismissal.rb @@ -15,6 +15,4 @@ class AnnouncementDismissal < ApplicationRecord inverse_of: :dismissals belongs_to :user, inverse_of: :announcement_dismissals - - validates :announcement, :user, presence: true end diff --git a/app/models/category.rb b/app/models/category.rb index 6267131809..3afa4a37c7 100644 --- a/app/models/category.rb +++ b/app/models/category.rb @@ -21,7 +21,8 @@ class Category < ApplicationRecord has_many :parent_relationships, class_name: 'CategoryRelationship', foreign_key: 'child_id', - dependent: :destroy + dependent: :destroy, + validate: false has_many :parents, through: :parent_relationships, source: :parent @@ -29,7 +30,8 @@ class Category < ApplicationRecord has_many :child_relationships, class_name: 'CategoryRelationship', foreign_key: 'parent_id', - dependent: :destroy + dependent: :destroy, + validate: false has_many :children, through: :child_relationships, source: :child, diff --git a/app/models/censor_rule.rb b/app/models/censor_rule.rb index 4548f21b2c..ae5a99306d 100644 --- a/app/models/censor_rule.rb +++ b/app/models/censor_rule.rb @@ -32,11 +32,14 @@ class CensorRule < ApplicationRecord ].freeze belongs_to :info_request, - inverse_of: :censor_rules + inverse_of: :censor_rules, + optional: true belongs_to :user, - inverse_of: :censor_rules + inverse_of: :censor_rules, + optional: true belongs_to :public_body, - inverse_of: :censor_rules + inverse_of: :censor_rules, + optional: true validate :require_valid_regexp, if: proc { |rule| rule.regexp? == true } diff --git a/app/models/citation.rb b/app/models/citation.rb index 92d5e4d837..67427af352 100644 --- a/app/models/citation.rb +++ b/app/models/citation.rb @@ -27,10 +27,9 @@ class Citation < ApplicationRecord belongs_to :user, inverse_of: :citations belongs_to :citable, polymorphic: true - belongs_to :info_request, via: :citable - belongs_to :info_request_batch, via: :citable + belongs_to :info_request, via: :citable, optional: true + belongs_to :info_request_batch, via: :citable, optional: true - validates :user, :citable, presence: true validates :citable_type, inclusion: { in: %w(InfoRequest InfoRequestBatch) } validates :source_url, length: { maximum: 255, message: _('Source URL is too long') }, diff --git a/app/models/comment.rb b/app/models/comment.rb index 458f26856f..e9e5353c00 100644 --- a/app/models/comment.rb +++ b/app/models/comment.rb @@ -41,16 +41,17 @@ class Comment < ApplicationRecord belongs_to :user, inverse_of: :comments, - counter_cache: true + counter_cache: true, + optional: true # has to be optional for controller action to work belongs_to :info_request, - inverse_of: :comments + inverse_of: :comments, + optional: true has_many :info_request_events, # in practice only ever has one inverse_of: :comment, dependent: :destroy - # validates_presence_of :user # breaks during construction of new ones :( validate :check_body_has_content, :check_body_uses_mixed_capitals diff --git a/app/models/dataset/key.rb b/app/models/dataset/key.rb index 2d4aef091f..da775ef78b 100644 --- a/app/models/dataset/key.rb +++ b/app/models/dataset/key.rb @@ -18,7 +18,7 @@ # resource # class Dataset::Key < ApplicationRecord - belongs_to :key_set, foreign_key: 'dataset_key_set_id' + belongs_to :key_set, foreign_key: 'dataset_key_set_id', optional: true has_many :values, foreign_key: 'dataset_key_id', inverse_of: :key default_scope -> { order(:order) } diff --git a/app/models/dataset/key_set.rb b/app/models/dataset/key_set.rb index 0fbea1cdf9..940b2bc241 100644 --- a/app/models/dataset/key_set.rb +++ b/app/models/dataset/key_set.rb @@ -26,6 +26,5 @@ class Dataset::KeySet < ApplicationRecord InfoRequestBatch ].freeze - validates :resource, presence: true validates :resource_type, inclusion: { in: RESOURCE_TYPES } end diff --git a/app/models/dataset/value_set.rb b/app/models/dataset/value_set.rb index 64cdd8b718..d76edf97d6 100644 --- a/app/models/dataset/value_set.rb +++ b/app/models/dataset/value_set.rb @@ -15,7 +15,7 @@ # A dataset collection of values # class Dataset::ValueSet < ApplicationRecord - belongs_to :resource, polymorphic: true + belongs_to :resource, polymorphic: true, optional: true belongs_to :key_set, foreign_key: 'dataset_key_set_id' has_many :values, foreign_key: 'dataset_value_set_id', inverse_of: :value_set @@ -27,7 +27,6 @@ class Dataset::ValueSet < ApplicationRecord FoiAttachment ].freeze - validates :key_set, :values, presence: true validates :resource_type, inclusion: { in: RESOURCE_TYPES }, if: :resource validates_associated :values validate :check_at_least_one_value_is_present diff --git a/app/models/draft_info_request.rb b/app/models/draft_info_request.rb index b5f718c3ca..671415dafe 100644 --- a/app/models/draft_info_request.rb +++ b/app/models/draft_info_request.rb @@ -17,11 +17,9 @@ class DraftInfoRequest < ApplicationRecord include AlaveteliPro::RequestSummaries include InfoRequest::DraftTitleValidation - validates_presence_of :user - belongs_to :user, inverse_of: :draft_info_requests - belongs_to :public_body, inverse_of: :draft_info_requests + belongs_to :public_body, inverse_of: :draft_info_requests, optional: true strip_attributes diff --git a/app/models/foi_attachment.rb b/app/models/foi_attachment.rb index 35e4259dea..4e04877d98 100644 --- a/app/models/foi_attachment.rb +++ b/app/models/foi_attachment.rb @@ -35,7 +35,7 @@ class FoiAttachment < ApplicationRecord MissingAttachment = Class.new(StandardError) - belongs_to :incoming_message, inverse_of: :foi_attachments + belongs_to :incoming_message, inverse_of: :foi_attachments, optional: true has_one :info_request, through: :incoming_message, source: :info_request has_one :raw_email, through: :incoming_message, source: :raw_email diff --git a/app/models/incoming_message.rb b/app/models/incoming_message.rb index 9024959087..129c43afa6 100644 --- a/app/models/incoming_message.rb +++ b/app/models/incoming_message.rb @@ -49,10 +49,6 @@ class IncomingMessage < ApplicationRecord inverse_of: :incoming_messages, counter_cache: true - validates_presence_of :info_request - - validates_presence_of :raw_email - has_many :outgoing_message_followups, inverse_of: :incoming_message_followup, foreign_key: 'incoming_message_followup_id', diff --git a/app/models/info_request.rb b/app/models/info_request.rb index 37be186146..2c48b43bba 100644 --- a/app/models/info_request.rb +++ b/app/models/info_request.rb @@ -67,15 +67,18 @@ def self.admin_title belongs_to :user, inverse_of: :info_requests, - counter_cache: true + counter_cache: true, + optional: true validate :must_be_internal_or_external belongs_to :public_body, inverse_of: :info_requests, - counter_cache: true + counter_cache: true, + validate: false belongs_to :info_request_batch, - inverse_of: :info_requests + inverse_of: :info_requests, + optional: true validates_presence_of :public_body, message: N_("Please select an authority") @@ -519,14 +522,13 @@ def self.download_zip_dir end def self.reject_incoming_at_mta(options) - query = InfoRequest.where(["updated_at < (now() - - interval ?) - AND allow_new_responses_from = 'nobody' - AND rejected_incoming_count >= ? - AND reject_incoming_at_mta = ? - AND url_title <> 'holding_pen'", - "#{options[:age_in_months]} months", - options[:rejection_threshold], false]) + query = InfoRequest.where( + updated_at: ...options[:age_in_months].months.ago, + rejected_incoming_count: options[:rejection_threshold].., + allow_new_responses_from: 'nobody', + reject_incoming_at_mta: false + ).where.not(url_title: 'holding_pen') + yield query.pluck(:id) if block_given? if options[:dryrun] diff --git a/app/models/info_request_batch.rb b/app/models/info_request_batch.rb index 5f38b36176..71d055d857 100644 --- a/app/models/info_request_batch.rb +++ b/app/models/info_request_batch.rb @@ -38,7 +38,6 @@ class InfoRequestBatch < ApplicationRecord attr_accessor :ignore_existing_batch - validates_presence_of :user validates_presence_of :body validates_absence_of :existing_batch, unless: -> { ignore_existing_batch }, diff --git a/app/models/info_request_event.rb b/app/models/info_request_event.rb index 1a1382ce9c..77474a4972 100644 --- a/app/models/info_request_event.rb +++ b/app/models/info_request_event.rb @@ -61,14 +61,15 @@ class InfoRequestEvent < ApplicationRecord belongs_to :info_request, inverse_of: :info_request_events - validates_presence_of :info_request - belongs_to :outgoing_message, - inverse_of: :info_request_events + inverse_of: :info_request_events, + optional: true belongs_to :incoming_message, - inverse_of: :info_request_events + inverse_of: :info_request_events, + optional: true belongs_to :comment, - inverse_of: :info_request_events + inverse_of: :info_request_events, + optional: true has_one :request_classification, inverse_of: :info_request_event diff --git a/app/models/mail_server_log.rb b/app/models/mail_server_log.rb index 25d6b9c1a2..3f4f148e6c 100644 --- a/app/models/mail_server_log.rb +++ b/app/models/mail_server_log.rb @@ -21,12 +21,14 @@ class MailServerLog < ApplicationRecord # `serialize` needs to be called before all other ActiveRecord code. # See http://stackoverflow.com/a/15610692/387558 - serialize :delivery_status, DeliveryStatusSerializer + serialize :delivery_status, coder: DeliveryStatusSerializer belongs_to :info_request, - inverse_of: :mail_server_logs + inverse_of: :mail_server_logs, + optional: true belongs_to :mail_server_log_done, - inverse_of: :mail_server_logs + inverse_of: :mail_server_logs, + optional: true before_create :calculate_delivery_status diff --git a/app/models/note.rb b/app/models/note.rb index 7145abf4df..2ee8933d10 100644 --- a/app/models/note.rb +++ b/app/models/note.rb @@ -35,7 +35,7 @@ class Note < ApplicationRecord default: Note.default_style, suffix: true - belongs_to :notable, polymorphic: true + belongs_to :notable, polymorphic: true, optional: true validates :body, presence: true, if: ->(n) { n.original_style? } validates :rich_body, presence: true, unless: ->(n) { n.original_style? } diff --git a/app/models/notification.rb b/app/models/notification.rb index e240251913..795f31b302 100644 --- a/app/models/notification.rb +++ b/app/models/notification.rb @@ -22,9 +22,9 @@ class Notification < ApplicationRecord INSTANTLY = :instantly DAILY = :daily - enum frequency: [ INSTANTLY, DAILY ] + enum :frequency, [ INSTANTLY, DAILY ] - validates_presence_of :info_request_event, :user, :frequency, :send_after + validates_presence_of :frequency, :send_after before_validation :calculate_send_after diff --git a/app/models/outgoing_message.rb b/app/models/outgoing_message.rb index dfa8e2d94a..ab2306e5dc 100644 --- a/app/models/outgoing_message.rb +++ b/app/models/outgoing_message.rb @@ -42,7 +42,6 @@ class OutgoingMessage < ApplicationRecord attr_accessor :default_letter before_validation :cache_from_name - validates_presence_of :info_request validates_presence_of :from_name, unless: -> (m) { !m.info_request&.user } validates_inclusion_of :status, in: STATUS_TYPES validates_inclusion_of :message_type, in: MESSAGE_TYPES @@ -56,7 +55,8 @@ class OutgoingMessage < ApplicationRecord belongs_to :incoming_message_followup, inverse_of: :outgoing_message_followups, foreign_key: 'incoming_message_followup_id', - class_name: 'IncomingMessage' + class_name: 'IncomingMessage', + optional: true has_one :user, inverse_of: :outgoing_messages, diff --git a/app/models/post_redirect.rb b/app/models/post_redirect.rb index 42fafa59bc..f5178b4803 100644 --- a/app/models/post_redirect.rb +++ b/app/models/post_redirect.rb @@ -34,7 +34,8 @@ class PostRedirect < ApplicationRecord # Optional, does a login confirm before redirect for use in email links. belongs_to :user, - inverse_of: :post_redirects + inverse_of: :post_redirects, + optional: true validates :circumstance, inclusion: CIRCUMSTANCES @@ -71,18 +72,14 @@ def post_params=(params) def post_params return {} if post_params_yaml.nil? - if RUBY_VERSION < "3.1" - YAML.load(post_params_yaml) - else - YAML.load( - post_params_yaml, - permitted_classes: [ - ActionController::Parameters, - ActiveSupport::HashWithIndifferentAccess, - Symbol - ] - ) - end + YAML.load( + post_params_yaml, + permitted_classes: [ + ActionController::Parameters, + ActiveSupport::HashWithIndifferentAccess, + Symbol + ] + ) end # We store YAML version of textual "reason for redirect" parameters @@ -109,7 +106,8 @@ def local_part_uri def email_token_valid? return true unless PostRedirect.verifier.valid_message?(email_token) - data = PostRedirect.verifier.verify(email_token, purpose: circumstance) + data = PostRedirect.verifier.verify(email_token, purpose: circumstance). + symbolize_keys user.id == data[:user_id] && user.login_token == data[:login_token] end diff --git a/app/models/profile_photo.rb b/app/models/profile_photo.rb index 0f70ad2578..da66bc4506 100644 --- a/app/models/profile_photo.rb +++ b/app/models/profile_photo.rb @@ -17,6 +17,8 @@ # Copyright (c) 2009 UK Citizens Online Democracy. All rights reserved. # Email: hello@mysociety.org; WWW: http://www.mysociety.org/ +require "mini_magick" + class ProfilePhoto < ApplicationRecord # deliberately don't strip_attributes, so keeps raw photo properly @@ -25,7 +27,8 @@ class ProfilePhoto < ApplicationRecord MAX_DRAFT = 500 # keep even pre-cropped images reasonably small belongs_to :user, - inverse_of: :profile_photo + inverse_of: :profile_photo, + optional: true validate :data_and_draft_checks diff --git a/app/models/project/membership.rb b/app/models/project/membership.rb index 5f62d3f46f..dddeb4d3a0 100644 --- a/app/models/project/membership.rb +++ b/app/models/project/membership.rb @@ -19,6 +19,4 @@ class Project::Membership < ApplicationRecord belongs_to :project belongs_to :user belongs_to :role - - validates :project, :user, :role, presence: true end diff --git a/app/models/project/resource.rb b/app/models/project/resource.rb index 89fc8344d7..35e2fd1006 100644 --- a/app/models/project/resource.rb +++ b/app/models/project/resource.rb @@ -18,6 +18,4 @@ class Project::Resource < ApplicationRecord belongs_to :project belongs_to :resource, polymorphic: true - - validates :project, :resource, presence: true end diff --git a/app/models/project/submission.rb b/app/models/project/submission.rb index ab7bc88b24..4084c0831f 100644 --- a/app/models/project/submission.rb +++ b/app/models/project/submission.rb @@ -21,7 +21,7 @@ class Project::Submission < ApplicationRecord belongs_to :project belongs_to :user belongs_to :info_request - belongs_to :resource, polymorphic: true + belongs_to :resource, polymorphic: true, optional: true scope :classification, -> { where(resource_type: 'InfoRequestEvent') } scope :extraction, -> { where(resource_type: 'Dataset::ValueSet') } @@ -31,7 +31,6 @@ class Project::Submission < ApplicationRecord Dataset::ValueSet ].freeze - validates :project, :user, :info_request, :resource, presence: true validates :resource_type, inclusion: { in: RESOURCE_TYPES } validates_associated :resource end diff --git a/app/models/public_body_category_link.rb b/app/models/public_body_category_link.rb index 8a6b799bcb..9f9ba3c846 100644 --- a/app/models/public_body_category_link.rb +++ b/app/models/public_body_category_link.rb @@ -18,9 +18,6 @@ class PublicBodyCategoryLink < ApplicationRecord belongs_to :public_body_heading, inverse_of: :public_body_category_links - validates_presence_of :public_body_category - validates_presence_of :public_body_heading - validates :category_display_order, numericality: { only_integer: true, message: 'Display order must be a number' } diff --git a/app/models/public_body_change_request.rb b/app/models/public_body_change_request.rb index 16bd3f87dc..6afab614ea 100644 --- a/app/models/public_body_change_request.rb +++ b/app/models/public_body_change_request.rb @@ -20,9 +20,11 @@ class PublicBodyChangeRequest < ApplicationRecord belongs_to :user, inverse_of: :public_body_change_requests, - counter_cache: true + counter_cache: true, + optional: true belongs_to :public_body, - inverse_of: :public_body_change_requests + inverse_of: :public_body_change_requests, + optional: true validates_presence_of :public_body_name, message: N_("Please enter the name of the authority"), diff --git a/app/models/role.rb b/app/models/role.rb index 1147dd8557..8826b5bb9b 100644 --- a/app/models/role.rb +++ b/app/models/role.rb @@ -19,7 +19,8 @@ class Role < ApplicationRecord inverse_of: :roles belongs_to :resource, - polymorphic: true + polymorphic: true, + optional: true validates :resource_type, inclusion: { in: Rolify.resource_types }, diff --git a/app/models/track_thing.rb b/app/models/track_thing.rb index 43be628d40..5e99d7f0e7 100644 --- a/app/models/track_thing.rb +++ b/app/models/track_thing.rb @@ -29,16 +29,19 @@ class TrackThing < ApplicationRecord TRACK_MEDIUMS = %w(email_daily feed) belongs_to :info_request, - inverse_of: :track_things + inverse_of: :track_things, + optional: true belongs_to :public_body, - inverse_of: :track_things + inverse_of: :track_things, + optional: true belongs_to :tracking_user, class_name: 'User', inverse_of: :track_things, counter_cache: true belongs_to :tracked_user, class_name: 'User', - inverse_of: :track_things + inverse_of: :track_things, + optional: true has_many :track_things_sent_emails, inverse_of: :track_thing, dependent: :destroy diff --git a/app/models/track_things_sent_email.rb b/app/models/track_things_sent_email.rb index 18bb3514bb..0be7a17ca1 100644 --- a/app/models/track_things_sent_email.rb +++ b/app/models/track_things_sent_email.rb @@ -20,11 +20,14 @@ class TrackThingsSentEmail < ApplicationRecord belongs_to :info_request_event, - inverse_of: :track_things_sent_emails + inverse_of: :track_things_sent_emails, + optional: true belongs_to :user, - inverse_of: :track_things_sent_emails + inverse_of: :track_things_sent_emails, + optional: true belongs_to :public_body, - inverse_of: :track_things_sent_emails + inverse_of: :track_things_sent_emails, + optional: true belongs_to :track_thing, inverse_of: :track_things_sent_emails diff --git a/app/models/user/sign_in.rb b/app/models/user/sign_in.rb index 159741080b..c8079c9be6 100644 --- a/app/models/user/sign_in.rb +++ b/app/models/user/sign_in.rb @@ -15,7 +15,7 @@ class User::SignIn < ApplicationRecord default_scope { order(created_at: :desc) } - belongs_to :user, inverse_of: :sign_ins + belongs_to :user, inverse_of: :sign_ins, optional: true before_create :create? diff --git a/app/models/user_info_request_sent_alert.rb b/app/models/user_info_request_sent_alert.rb index 0143b146c6..b709d4b2d9 100644 --- a/app/models/user_info_request_sent_alert.rb +++ b/app/models/user_info_request_sent_alert.rb @@ -43,7 +43,8 @@ class UserInfoRequestSentAlert < ApplicationRecord belongs_to :info_request, inverse_of: :user_info_request_sent_alerts belongs_to :info_request_event, - inverse_of: :user_info_request_sent_alerts + inverse_of: :user_info_request_sent_alerts, + optional: true validates_inclusion_of :alert_type, in: ALERT_TYPES diff --git a/app/models/user_message.rb b/app/models/user_message.rb index bb65c330c6..b5a2fa4bfd 100644 --- a/app/models/user_message.rb +++ b/app/models/user_message.rb @@ -11,5 +11,6 @@ class UserMessage < ApplicationRecord belongs_to :user, inverse_of: :user_messages, - counter_cache: true + counter_cache: true, + optional: true end diff --git a/app/models/widget_vote.rb b/app/models/widget_vote.rb index 85801e3ab3..d2737ea107 100644 --- a/app/models/widget_vote.rb +++ b/app/models/widget_vote.rb @@ -14,7 +14,6 @@ class WidgetVote < ApplicationRecord belongs_to :info_request, inverse_of: :widget_votes - validates :info_request, presence: true validates :cookie, length: { is: 20 } validates :cookie, uniqueness: { scope: :info_request_id } end diff --git a/bin/rails b/bin/rails index 6fb4e4051c..efc0377492 100755 --- a/bin/rails +++ b/bin/rails @@ -1,4 +1,4 @@ #!/usr/bin/env ruby -APP_PATH = File.expand_path('../config/application', __dir__) +APP_PATH = File.expand_path("../config/application", __dir__) require_relative "../config/boot" require "rails/commands" diff --git a/bin/setup b/bin/setup index 57923026c4..3cd5a9d780 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,21 +13,21 @@ 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") # 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 b1dee98822..83ed87ce74 100644 --- a/config/application.rb +++ b/config/application.rb @@ -12,7 +12,6 @@ require "action_text/engine" require "action_view/railtie" # require "action_cable/engine" -require "sprockets/railtie" # require "rails/test_unit/railtie" require File.dirname(__FILE__) + '/../lib/configuration' @@ -24,6 +23,29 @@ module Alaveteli class Application < Rails::Application + # Initialize configuration defaults for originally generated Rails version. + config.load_defaults 7.1 + + # Disable new framework default has_many_inversing breaks some specs due to + # an apparent regression in Rails + config.active_record.has_many_inversing = false # 6.1 + + # Please, add to the `ignore` list any other `lib` subdirectories that do + # not contain `.rb` files, or that should not be reloaded or eager loaded. + # Common ones are `templates`, `generators`, or `middleware`, for example. + config.autoload_lib( + ignore: %w( + acts_as_xapian + assets + core_ext + custom_cops + generators + has_tag_string + tasks + themes + ) + ) + # Configuration for the application, engines, and railties goes here. # # These settings can be overridden in specific environments using the files @@ -31,10 +53,9 @@ class Application < Rails::Application # # config.time_zone = "Central Time (US & Canada)" # config.eager_load_paths << Rails.root.join("extras") - config.autoloader = :zeitwerk - config.active_record.legacy_connection_handling = false - config.active_support.use_rfc4122_namespaced_uuids = true - config.active_storage.replace_on_assign_to_many = true + + # Don't generate system test files. + config.generators.system_tests = nil # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded. # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s] @@ -83,8 +104,6 @@ class Application < Rails::Application config.autoload_paths << "#{Rails.root}/app/controllers/concerns" config.autoload_paths << "#{Rails.root}/app/models/concerns" - config.enable_dependency_loading = true - # See Rails::Configuration for more options ENV['RECAPTCHA_SITE_KEY'] = AlaveteliConfiguration.recaptcha_site_key ENV['RECAPTCHA_SECRET_KEY'] = AlaveteliConfiguration.recaptcha_secret_key @@ -101,5 +120,7 @@ class Application < Rails::Application # Allow the generation of full URLs in emails config.action_mailer.default_url_options = { host: AlaveteliConfiguration.domain } + + config.active_storage.variant_processor = :mini_magick end end diff --git a/config/boot.rb b/config/boot.rb index 662856d3b3..65a0c8720c 100644 --- a/config/boot.rb +++ b/config/boot.rb @@ -1,4 +1,4 @@ -ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__) +ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__) require "bundler/setup" # Set up gems listed in the Gemfile. diff --git a/config/environments/development.rb b/config/environments/development.rb index 46dfdb6ada..0fff5f0a6e 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -6,7 +6,7 @@ # In the development environment your application's code is reloaded any time # it changes. This slows down response time but is perfect for development # since you don't have to restart the web server when you make code changes. - config.cache_classes = false + config.enable_reloading = true # Do not eager load code on boot. config.eager_load = false @@ -14,15 +14,18 @@ # 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? + if Rails.root.join("tmp/caching-dev.txt").exist? config.action_controller.perform_caching = true config.action_controller.enable_fragment_cache_logging = true config.cache_store = :memory_store config.public_file_server.headers = { - 'Cache-Control' => "public, max-age=#{2.days.to_i}" + "Cache-Control" => "public, max-age=#{2.days.to_i}" } else config.action_controller.perform_caching = false @@ -30,6 +33,9 @@ config.cache_store = :null_store end + # Store uploaded files on the local file system (see config/storage.yml for options). + config.active_storage.service = :local + # Don't care if the mailer can't send. config.action_mailer.raise_delivery_errors = false @@ -50,10 +56,8 @@ # Highlight code that triggered database queries in logs. config.active_record.verbose_query_logs = true - # Debug mode disables concatenation and preprocessing of assets. - # This option may cause significant delays in view rendering with a large - # number of complex assets. - config.assets.debug = ENV.key?('ASSETS_DEBUG') || false + # Highlight code that enqueued background job in logs. + config.active_job.verbose_enqueue_logs = true # Suppress logger output for asset requests. config.assets.quiet = true @@ -64,8 +68,8 @@ # Annotate rendered view with file names. # config.action_view.annotate_rendered_view_with_filenames = true - # Uncomment if you wish to allow Action Cable access from any origin. - # config.action_cable.disable_request_forgery_protection = true + # Raise error when a before_action's only/except options reference missing actions + config.action_controller.raise_on_missing_callback_actions = true # CUSTOM CONFIGURATION # @@ -73,9 +77,9 @@ # to make Rails upgrades easier. # ---------------------------------------------------------------- - config.action_mailer.preview_path = Rails.root.join( - 'spec', 'mailers', 'previews' - ) + config.action_mailer.preview_paths = [ + Rails.root.join('spec', 'mailers', 'previews') + ] # Set LOG_LEVEL in the environment to a valid log level to temporarily run the # application with a non-default setting. diff --git a/config/environments/production.rb b/config/environments/production.rb index dc04044cf5..02e60346d2 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -4,7 +4,7 @@ # Settings specified here will take precedence over those in config/application.rb. # Code is not reloaded between requests. - config.cache_classes = true + config.enable_reloading = false # Eager load code on boot. This eager loads most of Rails and # your application in memory, allowing both threaded web servers @@ -13,45 +13,57 @@ 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). + # 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. - config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present? + # Disable serving static files from `public/`, relying on NGINX/Apache to do so instead. + # config.public_file_server.enabled = false # Compress CSS using a preprocessor. # config.assets.css_compressor = :sass - # Do not fallback to assets pipeline if a precompiled asset is missed. + # Do not fall back to assets pipeline if a precompiled asset is missed. config.assets.compile = false # Enable serving of images, stylesheets, and JavaScripts from an asset server. - # config.asset_host = 'http://assets.example.com' + # config.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-Accel-Redirect' # for NGINX + # 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 + + # Assume all access to the app is happening through a SSL-terminating reverse proxy. + # Can be used together with config.force_ssl for Strict-Transport-Security and secure cookies. + # config.assume_ssl = true # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. config.force_ssl = AlaveteliConfiguration.force_ssl - # Include generic and useful information about system operation, but avoid logging too much - # information to avoid inadvertent exposure of personally identifiable information (PII). - config.log_level = ENV.fetch('LOG_LEVEL', :info) + # Log to STDOUT by default + config.logger = ActiveSupport::Logger.new(STDOUT) + .tap { |logger| logger.formatter = ::Logger::Formatter.new } + .then { |logger| ActiveSupport::TaggedLogging.new(logger) } # Prepend all log lines with the following tags. config.log_tags = [ :request_id ] + # "info" includes generic and useful information about system operation, but avoids logging too much + # information to avoid inadvertent exposure of personally identifiable information (PII). If you + # want to log everything, set the level to "debug". + config.log_level = ENV.fetch("RAILS_LOG_LEVEL", "info") + # Use a different cache store in production. # config.cache_store = :mem_cache_store # Use a real queuing backend for Active Job (and separate queues per environment). - # config.active_job.queue_adapter = :resque + # config.active_job.queue_adapter = :resque # config.active_job.queue_name_prefix = "alaveteli_production" config.action_mailer.perform_caching = false @@ -64,51 +76,19 @@ # the I18n.default_locale when a translation cannot be found). config.i18n.fallbacks = true - # Send deprecation notices to registered listeners. - config.active_support.deprecation = :notify - - # Log disallowed deprecations. - config.active_support.disallowed_deprecation = :log - - # Tell Active Support which deprecation messages to disallow. - config.active_support.disallowed_deprecation_warnings = [] - - # 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 + # Don't log any deprecations. + config.active_support.report_deprecations = false # 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 + # Enable DNS rebinding protection and other `Host` header attacks. + # config.hosts = [ + # "example.com", # Allow requests from example.com + # /.*\.example\.com/ # Allow requests from subdomains like `www.example.com` + # ] + # Skip DNS rebinding protection for the default health check endpoint. + # config.host_authorization = { exclude: ->(request) { request.path == "/up" } } # CUSTOM CONFIGURATION # diff --git a/config/environments/test.rb b/config/environments/test.rb index b8109c174c..4d7a99baf1 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -8,33 +8,35 @@ Rails.application.configure do # Settings specified here will take precedence over those in config/application.rb. - config.cache_classes = true + # 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 config.public_file_server.headers = { - 'Cache-Control' => "public, max-age=#{1.hour.to_i}" + "Cache-Control" => "public, max-age=#{1.hour.to_i}" } # 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 - # Use inline processing for Active Job - config.active_job.queue_adapter = :test - - # Raise exceptions instead of rendering exception templates. - config.action_dispatch.show_exceptions = false + # Render exception templates for rescuable exceptions and raise for other exceptions. + config.action_dispatch.show_exceptions = :rescuable # Disable request forgery protection in test environment. config.action_controller.allow_forgery_protection = false + # Store uploaded files on the local file system in a temporary directory. + config.active_storage.service = :test + config.action_mailer.perform_caching = false # Tell Action Mailer not to deliver emails to the real world. @@ -57,6 +59,9 @@ # 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 + # CUSTOM CONFIGURATION # # Always place custom environment config at the bottom of the file @@ -68,6 +73,10 @@ config.i18n.fallbacks = true config.i18n.enforce_available_locales = false + if ENV['DISABLE_DEPRECATION_WARNINGS'] + config.active_support.deprecation = :silence + end + unless ENV['RAILS_ENABLE_TEST_LOG'] config.logger = Logger.new(nil) config.log_level = :fatal @@ -83,4 +92,6 @@ exception_recipients: AlaveteliConfiguration.exception_notifications_to } end + + config.active_job.queue_adapter = :test end diff --git a/config/initializers/active_job_uniqueness.rb b/config/initializers/active_job_uniqueness.rb index d4a9cc5399..e11ca128da 100644 --- a/config/initializers/active_job_uniqueness.rb +++ b/config/initializers/active_job_uniqueness.rb @@ -1,5 +1,5 @@ require 'redis_connection' ActiveJob::Uniqueness.configure do |config| - config.redlock_servers = [RedisConnection.instance] + config.redlock_servers = [RedisConnection.client] end diff --git a/config/initializers/alaveteli.rb b/config/initializers/alaveteli.rb index 49b5faca9d..87a59cee61 100644 --- a/config/initializers/alaveteli.rb +++ b/config/initializers/alaveteli.rb @@ -10,7 +10,7 @@ load "util.rb" # Application version -ALAVETELI_VERSION = '0.45.0.0' +ALAVETELI_VERSION = '0.45.1.0' # Add new inflection rules using the following format # (all these examples are active by default): @@ -39,7 +39,6 @@ require 'attachment_to_html' require 'health_checks' require 'mail_handler' -require 'ability' require 'normalize_string' require 'alaveteli_file_types' require 'theme' diff --git a/config/initializers/assets.rb b/config/initializers/assets.rb index 82c9ad3fcb..2fff5fe8ca 100644 --- a/config/initializers/assets.rb +++ b/config/initializers/assets.rb @@ -1,7 +1,7 @@ # Be sure to restart your server when you modify this file. # Version of your assets, change this if you want to expire all your assets. -Rails.application.config.assets.version = '1.0' +Rails.application.config.assets.version = "1.0" # Add additional assets to the asset load path. # Rails.application.config.assets.paths << Emoji.images_path diff --git a/config/initializers/content_security_policy.rb b/config/initializers/content_security_policy.rb index 41c43016f1..b3076b38fe 100644 --- a/config/initializers/content_security_policy.rb +++ b/config/initializers/content_security_policy.rb @@ -1,28 +1,25 @@ # 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.config.content_security_policy do |policy| -# policy.default_src :self, :https -# policy.font_src :self, :https, :data -# policy.img_src :self, :https, :data -# policy.object_src :none -# policy.script_src :self, :https -# policy.style_src :self, :https - -# # Specify URI for violation reports -# # policy.report_uri "/csp-violation-report-endpoint" +# Rails.application.configure do +# config.content_security_policy do |policy| +# policy.default_src :self, :https +# policy.font_src :self, :https, :data +# policy.img_src :self, :https, :data +# policy.object_src :none +# policy.script_src :self, :https +# policy.style_src :self, :https +# # Specify URI for violation reports +# # policy.report_uri "/csp-violation-report-endpoint" +# end +# +# # 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 style-src) +# +# # Report violations without enforcing the policy. +# # config.content_security_policy_report_only = true # end - -# If you are using UJS then enable automatic nonce generation -# Rails.application.config.content_security_policy_nonce_generator = -> request { SecureRandom.base64(16) } - -# Set the nonce only to specific directives -# Rails.application.config.content_security_policy_nonce_directives = %w(script-src) - -# Report CSP violations to a specified URI -# For further information see the following documentation: -# https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy-Report-Only -# Rails.application.config.content_security_policy_report_only = true diff --git a/config/initializers/filter_parameter_logging.rb b/config/initializers/filter_parameter_logging.rb index 656e8ab03e..7b5946befc 100644 --- a/config/initializers/filter_parameter_logging.rb +++ b/config/initializers/filter_parameter_logging.rb @@ -1,6 +1,9 @@ +# rubocop:disable all # Be sure to restart your server when you modify this file. -# Configure sensitive parameters which will be filtered from the log file. +# 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, :_key, :crypt, :salt, :certificate, :otp, :ssn + :passw, :secret, :token, :_key, :crypt, :salt, :certificate, :otp, :ssn ] diff --git a/config/initializers/inflections.rb b/config/initializers/inflections.rb index cf573c56fc..37d3f5ba46 100644 --- a/config/initializers/inflections.rb +++ b/config/initializers/inflections.rb @@ -4,13 +4,17 @@ # 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" +# end + ActiveSupport::Inflector.inflections(:en) do |inflect| inflect.acronym 'HTML' inflect.acronym 'RTF' diff --git a/config/initializers/new_framework_defaults.rb b/config/initializers/new_framework_defaults.rb deleted file mode 100644 index a2bfed3009..0000000000 --- a/config/initializers/new_framework_defaults.rb +++ /dev/null @@ -1,20 +0,0 @@ -# Be sure to restart your server when you modify this file. -# -# This file contains migration options to ease your Rails 5.0 upgrade. -# -# Once upgraded flip defaults one by one to migrate to the new default. -# -# Read the Guide for Upgrading Ruby on Rails for more info on each option. - -# Enable per-form CSRF tokens. Previous versions had false. -Rails.application.config.action_controller.per_form_csrf_tokens = false - -# Enable origin-checking CSRF mitigation. Previous versions had false. -Rails.application.config.action_controller.forgery_protection_origin_check = false - -# Make Ruby 2.4 preserve the timezone of the receiver when calling `to_time`. -# Previous versions had false. -ActiveSupport.to_time_preserves_timezone = false - -# Require `belongs_to` associations by default. Previous versions had false. -Rails.application.config.active_record.belongs_to_required_by_default = false diff --git a/config/initializers/new_framework_defaults_5_2.rb b/config/initializers/new_framework_defaults_5_2.rb deleted file mode 100644 index c383d072bc..0000000000 --- a/config/initializers/new_framework_defaults_5_2.rb +++ /dev/null @@ -1,38 +0,0 @@ -# Be sure to restart your server when you modify this file. -# -# This file contains migration options to ease your Rails 5.2 upgrade. -# -# Once upgraded flip defaults one by one to migrate to the new default. -# -# Read the Guide for Upgrading Ruby on Rails for more info on each option. - -# Make Active Record use stable #cache_key alongside new #cache_version method. -# This is needed for recyclable cache keys. -# Rails.application.config.active_record.cache_versioning = true - -# Use AES-256-GCM authenticated encryption for encrypted cookies. -# Also, embed cookie expiry in signed or encrypted cookies for increased security. -# -# This option is not backwards compatible with earlier Rails versions. -# It's best enabled when your entire app is migrated and stable on 5.2. -# -# Existing cookies will be converted on read then written with the new scheme. -# Rails.application.config.action_dispatch.use_authenticated_cookie_encryption = true - -# Use AES-256-GCM authenticated encryption as default cipher for encrypting messages -# instead of AES-256-CBC, when use_authenticated_message_encryption is set to true. -# Rails.application.config.active_support.use_authenticated_message_encryption = true - -# Add default protection from forgery to ActionController::Base instead of in -# ApplicationController. -# Rails.application.config.action_controller.default_protect_from_forgery = true - -# Store boolean values are in sqlite3 databases as 1 and 0 instead of 't' and -# 'f' after migrating old data. -# Rails.application.config.active_record.sqlite3.represent_boolean_as_integer = true - -# Use SHA-1 instead of MD5 to generate non-sensitive digests, such as the ETag header. -# Rails.application.config.active_support.use_sha1_digests = true - -# Make `form_with` generate id attributes for any generated HTML tags. -# Rails.application.config.action_view.form_with_generates_ids = true diff --git a/config/initializers/new_framework_defaults_6_0.rb b/config/initializers/new_framework_defaults_6_0.rb deleted file mode 100644 index 92240ef5f5..0000000000 --- a/config/initializers/new_framework_defaults_6_0.rb +++ /dev/null @@ -1,45 +0,0 @@ -# Be sure to restart your server when you modify this file. -# -# This file contains migration options to ease your Rails 6.0 upgrade. -# -# Once upgraded flip defaults one by one to migrate to the new default. -# -# Read the Guide for Upgrading Ruby on Rails for more info on each option. - -# Don't force requests from old versions of IE to be UTF-8 encoded. -# Rails.application.config.action_view.default_enforce_utf8 = false - -# Embed purpose and expiry metadata inside signed and encrypted -# cookies for increased security. -# -# This option is not backwards compatible with earlier Rails versions. -# It's best enabled when your entire app is migrated and stable on 6.0. -# Rails.application.config.action_dispatch.use_cookies_with_metadata = true - -# Change the return value of `ActionDispatch::Response#content_type` to Content-Type header without modification. -# Rails.application.config.action_dispatch.return_only_media_type_on_content_type = false - -# Return false instead of self when enqueuing is aborted from a callback. -# Rails.application.config.active_job.return_false_on_aborted_enqueue = true - -# Send Active Storage analysis and purge jobs to dedicated queues. -# Rails.application.config.active_storage.queues.analysis = :active_storage_analysis -# Rails.application.config.active_storage.queues.purge = :active_storage_purge - -# When assigning to a collection of attachments declared via `has_many_attached`, replace existing -# attachments instead of appending. Use #attach to add new attachments without replacing existing ones. -# Rails.application.config.active_storage.replace_on_assign_to_many = true - -# Use ActionMailer::MailDeliveryJob for sending parameterized and normal mail. -# -# The default delivery jobs (ActionMailer::Parameterized::DeliveryJob, ActionMailer::DeliveryJob), -# will be removed in Rails 6.1. This setting is not backwards compatible with earlier Rails versions. -# If you send mail in the background, job workers need to have a copy of -# MailDeliveryJob to ensure all delivery jobs are processed properly. -# Make sure your entire app is migrated and stable on 6.0 before using this setting. -# Rails.application.config.action_mailer.delivery_job = "ActionMailer::MailDeliveryJob" - -# Enable the same cache key to be reused when the object being cached of type -# `ActiveRecord::Relation` changes by moving the volatile information (max updated at and count) -# of the relation's cache key into the cache version to support recycling cache key. -# Rails.application.config.active_record.collection_cache_versioning = true diff --git a/config/initializers/new_framework_defaults_6_1.rb b/config/initializers/new_framework_defaults_6_1.rb deleted file mode 100644 index 9526b835ab..0000000000 --- a/config/initializers/new_framework_defaults_6_1.rb +++ /dev/null @@ -1,67 +0,0 @@ -# Be sure to restart your server when you modify this file. -# -# This file contains migration options to ease your Rails 6.1 upgrade. -# -# Once upgraded flip defaults one by one to migrate to the new default. -# -# Read the Guide for Upgrading Ruby on Rails for more info on each option. - -# Support for inversing belongs_to -> has_many Active Record associations. -# Rails.application.config.active_record.has_many_inversing = true - -# Track Active Storage variants in the database. -# Rails.application.config.active_storage.track_variants = true - -# Apply random variation to the delay when retrying failed jobs. -# Rails.application.config.active_job.retry_jitter = 0.15 - -# Stop executing `after_enqueue`/`after_perform` callbacks if -# `before_enqueue`/`before_perform` respectively halts with `throw :abort`. -# Rails.application.config.active_job.skip_after_callbacks_if_terminated = true - -# Specify cookies SameSite protection level: either :none, :lax, or :strict. -# -# This change is not backwards compatible with earlier Rails versions. -# It's best enabled when your entire app is migrated and stable on 6.1. -# Rails.application.config.action_dispatch.cookies_same_site_protection = :lax - -# Generate CSRF tokens that are encoded in URL-safe Base64. -# -# This change is not backwards compatible with earlier Rails versions. -# It's best enabled when your entire app is migrated and stable on 6.1. -# Rails.application.config.action_controller.urlsafe_csrf_tokens = true - -# Specify whether `ActiveSupport::TimeZone.utc_to_local` returns a time with an -# UTC offset or a UTC time. -# ActiveSupport.utc_to_local_returns_utc_offset_times = true - -# Change the default HTTP status code to `308` when redirecting non-GET/HEAD -# requests to HTTPS in `ActionDispatch::SSL` middleware. -# Rails.application.config.action_dispatch.ssl_default_redirect_status = 308 - -# Use new connection handling API. For most applications this won't have any -# effect. For applications using multiple databases, this new API provides -# support for granular connection swapping. -# Rails.application.config.active_record.legacy_connection_handling = false - -# Make `form_with` generate non-remote forms by default. -# Rails.application.config.action_view.form_with_generates_remote_forms = false - -# Set the default queue name for the analysis job to the queue adapter default. -# Rails.application.config.active_storage.queues.analysis = nil - -# Set the default queue name for the purge job to the queue adapter default. -# Rails.application.config.active_storage.queues.purge = nil - -# Set the default queue name for the incineration job to the queue adapter default. -# Rails.application.config.action_mailbox.queues.incineration = nil - -# Set the default queue name for the routing job to the queue adapter default. -# Rails.application.config.action_mailbox.queues.routing = nil - -# Set the default queue name for the mail deliver job to the queue adapter default. -# Rails.application.config.action_mailer.deliver_later_queue_name = nil - -# Generate a `Link` header that gives a hint to modern browsers about -# preloading assets when using `javascript_include_tag` and `stylesheet_link_tag`. -# Rails.application.config.action_view.preload_links_header = true diff --git a/config/initializers/new_framework_defaults_7_0.rb b/config/initializers/new_framework_defaults_7_0.rb deleted file mode 100644 index 1cd17e47f7..0000000000 --- a/config/initializers/new_framework_defaults_7_0.rb +++ /dev/null @@ -1,141 +0,0 @@ -# Be sure to restart your server when you modify this file. -# -# This file eases your Rails 7.0 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.0`. -# -# Read the Guide for Upgrading Ruby on Rails for more info on each option. -# https://guides.rubyonrails.org/upgrading_ruby_on_rails.html - -# `button_to` view helper will render `