From ab03ffef042d0060f61e0dd551befd58630a1565 Mon Sep 17 00:00:00 2001 From: Tim Morgan Date: Fri, 12 Jan 2024 17:08:38 -0800 Subject: [PATCH] Ruby 3.3, Rails 7.1 --- .github/workflows/{ruby.yml => ci.yml} | 27 +-- .ruby-version | 2 +- Gemfile | 2 +- Gemfile.lock | 207 +++++++++--------- README.md | 8 +- app/controllers/sessions_controller.rb | 2 +- bin/setup | 2 +- config/application.rb | 10 +- config/deploy.rb | 2 +- config/deploy/production.rb | 2 +- config/environments/development.rb | 11 +- config/environments/production.rb | 53 +++-- config/environments/test.rb | 23 +- .../initializers/content_security_policy.rb | 6 +- config/initializers/cors.rb | 2 +- .../initializers/filter_parameter_logging.rb | 6 +- config/initializers/inflections.rb | 13 +- config/routes.rb | 2 - tmp/.gitignore | 1 + 19 files changed, 201 insertions(+), 180 deletions(-) rename .github/workflows/{ruby.yml => ci.yml} (85%) create mode 100644 tmp/.gitignore diff --git a/.github/workflows/ruby.yml b/.github/workflows/ci.yml similarity index 85% rename from .github/workflows/ruby.yml rename to .github/workflows/ci.yml index e96f0e7..af11a04 100644 --- a/.github/workflows/ruby.yml +++ b/.github/workflows/ci.yml @@ -5,7 +5,7 @@ # This workflow will download a prebuilt Ruby version, install dependencies and run tests with Rake # For more information see: https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby -name: Ruby +name: CI on: push: @@ -21,6 +21,7 @@ jobs: postgres: image: postgres:15 env: + POSTGRES_DB: flyweight_test POSTGRES_USER: flyweight POSTGRES_PASSWORD: postgres options: >- @@ -40,21 +41,24 @@ jobs: ports: - "6379:6379" steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Set up Ruby uses: ruby/setup-ruby@v1 with: - ruby-version: "3.2" + ruby-version: "3.3" bundler-cache: true - name: Create test database env: + POSTGRES_DB: flyweight_test POSTGRES_USER: flyweight POSTGRES_PASSWORD: postgres RAILS_MASTER_KEY: ${{ secrets.RAILS_MASTER_KEY }} - RAILS_ENV: test - run: bin/rails db:setup + run: | + sudo apt-get install libpq-dev + RAILS_ENV=test bin/rails db:setup - name: Run unit tests env: + POSTGRES_DB: flyweight_test POSTGRES_USER: flyweight POSTGRES_PASSWORD: postgres RAILS_MASTER_KEY: ${{ secrets.RAILS_MASTER_KEY }} @@ -64,11 +68,11 @@ jobs: name: Linters runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Set up Ruby uses: ruby/setup-ruby@v1 with: - ruby-version: "3.2" + ruby-version: "3.3" bundler-cache: true - name: Run Rubocop run: | @@ -83,11 +87,4 @@ jobs: mv .rubocop2.yml .rubocop.yml rubocop --parallel - name: Run Brakeman - run: | - #gem install brakeman - git clone https://github.com/presidentbeef/brakeman.git - pushd brakeman - gem build brakeman.gemspec - gem install brakeman*.gem - popd - brakeman -q -w2 + uses: artplan1/brakeman-action@v1 diff --git a/.ruby-version b/.ruby-version index be94e6f..15a2799 100644 --- a/.ruby-version +++ b/.ruby-version @@ -1 +1 @@ -3.2.2 +3.3.0 diff --git a/Gemfile b/Gemfile index 67916cf..17b25c7 100644 --- a/Gemfile +++ b/Gemfile @@ -3,7 +3,7 @@ source "https://rubygems.org" git_source(:github) { |repo| "https://github.com/#{repo}.git" } -ruby "3.2.2" +ruby "3.3.0" # CORE gem "puma" diff --git a/Gemfile.lock b/Gemfile.lock index e520b81..f74c829 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,35 +1,35 @@ GEM remote: https://rubygems.org/ specs: - actioncable (7.1.2) - actionpack (= 7.1.2) - activesupport (= 7.1.2) + actioncable (7.1.3.2) + actionpack (= 7.1.3.2) + activesupport (= 7.1.3.2) nio4r (~> 2.0) websocket-driver (>= 0.6.1) zeitwerk (~> 2.6) - actionmailbox (7.1.2) - actionpack (= 7.1.2) - activejob (= 7.1.2) - activerecord (= 7.1.2) - activestorage (= 7.1.2) - activesupport (= 7.1.2) + 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.1.2) - actionpack (= 7.1.2) - actionview (= 7.1.2) - activejob (= 7.1.2) - activesupport (= 7.1.2) + 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.2) - actionpack (7.1.2) - actionview (= 7.1.2) - activesupport (= 7.1.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) @@ -37,35 +37,35 @@ GEM rack-test (>= 0.6.3) rails-dom-testing (~> 2.2) rails-html-sanitizer (~> 1.6) - actiontext (7.1.2) - actionpack (= 7.1.2) - activerecord (= 7.1.2) - activestorage (= 7.1.2) - activesupport (= 7.1.2) + 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.1.2) - activesupport (= 7.1.2) + actionview (7.1.3.2) + activesupport (= 7.1.3.2) builder (~> 3.1) erubi (~> 1.11) rails-dom-testing (~> 2.2) rails-html-sanitizer (~> 1.6) - activejob (7.1.2) - activesupport (= 7.1.2) + activejob (7.1.3.2) + activesupport (= 7.1.3.2) globalid (>= 0.3.6) - activemodel (7.1.2) - activesupport (= 7.1.2) - activerecord (7.1.2) - activemodel (= 7.1.2) - activesupport (= 7.1.2) + 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) - activestorage (7.1.2) - actionpack (= 7.1.2) - activejob (= 7.1.2) - activerecord (= 7.1.2) - activesupport (= 7.1.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) - activesupport (7.1.2) + activesupport (7.1.3.2) base64 bigdecimal concurrent-ruby (~> 1.0, >= 1.0.2) @@ -75,17 +75,17 @@ GEM minitest (>= 5.1) mutex_m tzinfo (~> 2.0) - addressable (2.8.5) + addressable (2.8.6) public_suffix (>= 2.0.2, < 6.0) - airbrussh (1.5.0) + airbrussh (1.5.1) sshkit (>= 1.6.1, != 1.7.0) base64 (0.2.0) bcrypt (3.1.20) bcrypt_pbkdf (1.1.0) - bigdecimal (3.1.4) + bigdecimal (3.1.6) binding_of_caller (1.0.0) debug_inspector (>= 0.0.1) - bugsnag (6.26.0) + bugsnag (6.26.3) concurrent-ruby (~> 1.0) bugsnag-capistrano (2.1.0) builder (3.2.4) @@ -110,9 +110,10 @@ GEM capistrano (>= 3.9.0) capistrano-bundler sidekiq (>= 6.0) - concurrent-ruby (1.2.2) + concurrent-ruby (1.2.3) connection_pool (2.4.1) - crack (0.4.5) + crack (1.0.0) + bigdecimal rexml crass (1.0.6) database_cleaner (2.0.2) @@ -122,7 +123,7 @@ GEM database_cleaner-core (~> 2.0.0) database_cleaner-core (2.0.1) date (3.3.4) - debug_inspector (1.1.0) + debug_inspector (1.2.0) devise (4.9.3) bcrypt (~> 3.0) orm_adapter (~> 0.1) @@ -132,7 +133,7 @@ GEM devise-jwt (0.11.0) devise (~> 4.0) warden-jwt_auth (~> 0.8) - diff-lcs (1.5.0) + diff-lcs (1.5.1) drb (2.2.0) ruby2_keywords dry-auto_inject (1.0.1) @@ -146,26 +147,27 @@ GEM zeitwerk (~> 2.6) ed25519 (1.3.0) erubi (1.12.0) - factory_bot (6.4.2) + factory_bot (6.4.6) activesupport (>= 5.0.0) - factory_bot_rails (6.4.2) + factory_bot_rails (6.4.3) factory_bot (~> 6.4) railties (>= 5.0.0) ffaker (2.23.0) globalid (1.2.1) activesupport (>= 6.1) - hashdiff (1.0.1) + hashdiff (1.1.0) i18n (1.14.1) concurrent-ruby (~> 1.0) - io-console (0.6.0) - irb (1.9.1) + io-console (0.7.2) + irb (1.11.2) rdoc - reline (>= 0.3.8) + reline (>= 0.4.2) jbuilder (2.11.5) actionview (>= 5.0.0) activesupport (>= 5.0.0) json_expressions (0.9.0) - jwt (2.7.1) + jwt (2.8.0) + base64 loofah (2.22.0) crass (~> 1.0.2) nokogiri (>= 1.12.0) @@ -176,9 +178,9 @@ GEM net-smtp marcel (1.0.2) mini_mime (1.1.5) - minitest (5.20.0) + minitest (5.22.2) mutex_m (0.2.0) - net-imap (0.4.6) + net-imap (0.4.10) date net-protocol net-pop (0.1.2) @@ -187,23 +189,25 @@ GEM timeout net-scp (4.0.0) net-ssh (>= 2.6.5, < 8.0.0) - net-smtp (0.4.0) + net-sftp (4.0.0) + net-ssh (>= 5.0.0, < 8.0.0) + net-smtp (0.4.0.1) net-protocol - net-ssh (7.2.0) - nio4r (2.6.1) - nokogiri (1.15.5-arm64-darwin) + net-ssh (7.2.1) + nio4r (2.7.0) + nokogiri (1.16.2-arm64-darwin) racc (~> 1.4) - nokogiri (1.15.5-x86_64-linux) + nokogiri (1.16.2-x86_64-linux) racc (~> 1.4) orm_adapter (0.5.0) - pg (1.5.4) - psych (5.1.1.1) + pg (1.5.5) + psych (5.1.2) stringio public_suffix (5.0.4) - puma (6.4.0) + puma (6.4.2) nio4r (~> 2.0) racc (1.7.3) - rack (3.0.8) + rack (3.0.9.1) rack-cors (2.0.1) rack (>= 2.0.0) rack-session (2.0.0) @@ -213,20 +217,20 @@ GEM rackup (2.1.0) rack (>= 3) webrick (~> 1.8) - rails (7.1.2) - actioncable (= 7.1.2) - actionmailbox (= 7.1.2) - actionmailer (= 7.1.2) - actionpack (= 7.1.2) - actiontext (= 7.1.2) - actionview (= 7.1.2) - activejob (= 7.1.2) - activemodel (= 7.1.2) - activerecord (= 7.1.2) - activestorage (= 7.1.2) - activesupport (= 7.1.2) + 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.1.2) + railties (= 7.1.3.2) rails-controller-testing (1.0.5) actionpack (>= 5.0.1.rc1) actionview (>= 5.0.1.rc1) @@ -238,37 +242,37 @@ GEM rails-html-sanitizer (1.6.0) loofah (~> 2.21) nokogiri (~> 1.14) - railties (7.1.2) - actionpack (= 7.1.2) - activesupport (= 7.1.2) + 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, >= 1.2.2) zeitwerk (~> 2.6) rake (13.1.0) - rdoc (6.6.0) + rdoc (6.6.2) psych (>= 4.0.0) redcarpet (3.6.0) - redis (5.0.8) + redis (5.1.0) redis-client (>= 0.17.0) - redis-client (0.18.0) + redis-client (0.20.0) connection_pool - reline (0.4.0) + reline (0.4.3) io-console (~> 0.5) responders (3.1.1) actionpack (>= 5.2) railties (>= 5.2) rexml (3.2.6) - rspec-core (3.12.2) - rspec-support (~> 3.12.0) - rspec-expectations (3.12.3) + 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.6) + 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.1.0) + rspec-support (~> 3.13.0) + rspec-rails (6.1.1) actionpack (>= 6.1) activesupport (>= 6.1) railties (>= 6.1) @@ -276,18 +280,20 @@ GEM rspec-expectations (~> 3.12) rspec-mocks (~> 3.12) rspec-support (~> 3.12) - rspec-support (3.12.1) + rspec-support (3.13.1) ruby2_keywords (0.0.5) - sidekiq (7.2.0) + sidekiq (7.2.2) concurrent-ruby (< 2) connection_pool (>= 2.3.0) rack (>= 2.2.4) - redis-client (>= 0.14.0) - sshkit (1.21.6) + redis-client (>= 0.19.0) + sshkit (1.22.0) + mutex_m net-scp (>= 1.1.2) + net-sftp (>= 2.1.2) net-ssh (>= 2.8.0) - stringio (3.0.9) - thor (1.3.0) + stringio (3.1.0) + thor (1.3.1) timeout (0.4.1) tzinfo (2.0.6) concurrent-ruby (~> 1.0) @@ -298,7 +304,7 @@ GEM dry-configurable (>= 0.13, < 2) jwt (~> 2.1) warden (~> 1.2) - webmock (3.19.1) + webmock (3.23.0) addressable (>= 2.8.0) crack (>= 0.3.2) hashdiff (>= 0.4.0, < 2.0.0) @@ -307,10 +313,11 @@ GEM websocket-extensions (>= 0.1.0) websocket-extensions (0.1.5) yard (0.9.34) - zeitwerk (2.6.12) + zeitwerk (2.6.13) PLATFORMS arm64-darwin-22 + arm64-darwin-23 x86_64-linux DEPENDENCIES @@ -347,7 +354,7 @@ DEPENDENCIES yard RUBY VERSION - ruby 3.2.2p53 + ruby 3.3.0p0 BUNDLED WITH - 2.4.22 + 2.5.6 diff --git a/README.md b/README.md index 3c56cda..23b1bae 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ giving passengers a basic assurance of privacy. ### Installation and Running -FlyWeight requires Ruby 3.2, PostgreSQL, and Redis. (If you use Homebrew, +FlyWeight requires Ruby 3.3, PostgreSQL, and Redis. (If you use Homebrew, you can install those dependencies with `brew install`.) After cloning the repository, run `bundle install` to install all gem requirements. Run `rails db:create db:migrate` to create the development database. @@ -24,10 +24,10 @@ To run the server in development mode, you can create a `Procfile` with contents such as: ``` -backend: cd Backend && rvm 3.2.2@flyweight exec rails server +backend: cd Backend && rvm 3.3.0@flyweight exec rails server frontend: cd Frontend && yarn dev -jobs: cd Backend && rvm 3.2.2@flyweight exec bundle exec sidekiq -C config/sidekiq.yml -cable: cd Backend && rvm 3.2.2@flyweight exec ./bin/cable +jobs: cd Backend && rvm 3.3.0@flyweight exec bundle exec sidekiq -C config/sidekiq.yml +cable: cd Backend && rvm 3.3.0@flyweight exec ./bin/cable ``` Install the `foreman` gem to run the Procfile. diff --git a/app/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb index b026963..d673d46 100644 --- a/app/controllers/sessions_controller.rb +++ b/app/controllers/sessions_controller.rb @@ -8,7 +8,7 @@ class SessionsController < Devise::SessionsController def sign_in(resource_or_scope, *args) options = args.extract_options! - super resource_or_scope, *args, options.merge(store: false) + super(resource_or_scope, *args, options.merge(store: false)) end def respond_with(_resource, _opts={}) diff --git a/bin/setup b/bin/setup index ec47b79..3cd5a9d 100755 --- a/bin/setup +++ b/bin/setup @@ -5,7 +5,7 @@ require "fileutils" 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 diff --git a/config/application.rb b/config/application.rb index d33af73..159814c 100644 --- a/config/application.rb +++ b/config/application.rb @@ -26,7 +26,13 @@ class Application < Rails::Application config.app_generators.scaffold_controller :responders_controller # Initialize configuration defaults for originally generated Rails version. - config.load_defaults 7.0 + config.load_defaults 7.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[assets tasks]) + config.autoload_paths << Rails.root.join('app', 'middleware') # Configuration for the application, engines, and railties goes here. # @@ -57,6 +63,8 @@ class Application < Rails::Application config.action_cable.url = config.urls.cable config.action_cable.allowed_request_origins = [config.urls.frontend] + config.active_record.encryption.support_sha1_for_non_deterministic_encryption = false + backend = URI.parse(Rails.application.config.urls.backend) Rails.application.routes.default_url_options = { host: backend.host, diff --git a/config/deploy.rb b/config/deploy.rb index f6bcc04..5e0ca9f 100644 --- a/config/deploy.rb +++ b/config/deploy.rb @@ -20,7 +20,7 @@ append :linked_dirs, "log", "tmp/pids", "tmp/cache", "tmp/sockets", "node_modules", "public/packs", "public/assets" -set :rvm_ruby_version, "3.2.2@#{fetch :application}" +set :rvm_ruby_version, "3.3.0@#{fetch :application}" set :sidekiq_config, "config/sidekiq.yml" diff --git a/config/deploy/production.rb b/config/deploy/production.rb index aefc549..04c7e3f 100644 --- a/config/deploy/production.rb +++ b/config/deploy/production.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true -server "timothymorgan.info", +server "app.flyweight.org", user: "deploy", roles: %w[app db web] diff --git a/config/environments/development.rb b/config/environments/development.rb index 5f63319..d4e811c 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -8,7 +8,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 @@ -32,9 +32,6 @@ 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 @@ -55,6 +52,9 @@ # Highlight code that triggered database queries in logs. config.active_record.verbose_query_logs = true + # Highlight code that enqueued background job in logs. + config.active_job.verbose_enqueue_logs = true + # Raises error for missing translations. # config.i18n.raise_on_missing_translations = true @@ -63,4 +63,7 @@ # Uncomment if you wish to allow Action Cable access from any origin. # config.action_cable.disable_request_forgery_protection = true + + # Raise error when a before_action's only/except options reference missing actions + config.action_controller.raise_on_missing_callback_actions = true end diff --git a/config/environments/production.rb b/config/environments/production.rb index 8dd7b89..e691621 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -6,7 +6,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 @@ -17,13 +17,12 @@ # Full error reports are disabled and caching is turned on. config.consider_all_requests_local = false - # 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 # Enable serving of images, stylesheets, and JavaScripts from an asset server. # config.asset_host = "http://assets.example.com" @@ -32,28 +31,36 @@ # 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.*/ ] + + # Assume all access to the app is happening through a SSL-terminating reverse proxy. + # Can be used together with config.force_ssl for Strict-Transport-Security and secure cookies. + # config.assume_ssl = true # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. - # config.force_ssl = true + config.force_ssl = true - # Include generic and useful information about system operation, but avoid logging too much - # information to avoid inadvertent exposure of personally identifiable information (PII). - config.log_level = :info + # Log to STDOUT by default + config.logger = ActiveSupport::Logger.new($stdout). + tap { |logger| logger.formatter = Logger::Formatter.new }. + then { |logger| ActiveSupport::TaggedLogging.new(logger) } # Prepend all log lines with the following tags. config.log_tags = %i[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 = :sidekiq + # config.active_job.queue_adapter = :resque # config.active_job.queue_name_prefix = "flyweight_production" config.action_mailer.perform_caching = false @@ -69,19 +76,11 @@ # Don't log any deprecations. config.active_support.report_deprecations = false - # Use default logging formatter so that PID and timestamp are not suppressed. - config.log_formatter = Logger::Formatter.new - - # Use a different logger for distributed setups. - # require "syslog/logger" - # config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new "app-name") - - if ENV["RAILS_LOG_TO_STDOUT"].present? - logger = ActiveSupport::Logger.new($stdout) - logger.formatter = config.log_formatter - config.logger = ActiveSupport::TaggedLogging.new(logger) - end - # Do not dump schema after migrations. config.active_record.dump_schema_after_migration = false + + # Enable DNS rebinding protection and other `Host` header attacks. + config.hosts = %w[flyweight.org app.flyweight.org] + # Skip DNS rebinding protection for the default health check endpoint. + # config.host_authorization = { exclude: ->(request) { request.path == "/up" } } end diff --git a/config/environments/test.rb b/config/environments/test.rb index 0502be6..f0a4fd0 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -10,12 +10,13 @@ Rails.application.configure do # Settings specified here will take precedence over those in config/application.rb. - # Turn false under Spring and add config.action_view.cache_template_loading = true. - config.cache_classes = true + # While tests run files are not watched, reloading is not necessary. + config.enable_reloading = false - # Eager loading loads your whole application. When running a single test locally, - # this probably isn't necessary. It's a good idea to do in a continuous integration - # system, or in some way before deploying your code. + # Eager loading loads your entire application. When running a single test locally, + # this is usually not necessary, and can slow down your test suite. However, it's + # recommended that you enable it in continuous integration systems to ensure eager + # loading is working properly before deploying your code. config.eager_load = ENV["CI"].present? # Configure public file server for tests with Cache-Control for performance. @@ -25,19 +26,16 @@ } # 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 = :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. @@ -60,5 +58,8 @@ # 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 + config.active_job.queue_adapter = :test end diff --git a/config/initializers/content_security_policy.rb b/config/initializers/content_security_policy.rb index 7905699..88f3a14 100644 --- a/config/initializers/content_security_policy.rb +++ b/config/initializers/content_security_policy.rb @@ -2,9 +2,9 @@ # 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 # Bugsnag requires: # - connect-src 'https://sessions.bugsnag.com' diff --git a/config/initializers/cors.rb b/config/initializers/cors.rb index f908584..ab57d42 100644 --- a/config/initializers/cors.rb +++ b/config/initializers/cors.rb @@ -3,7 +3,7 @@ # Be sure to restart your server when you modify this file. # Avoid CORS issues when API is called from the frontend app. -# Handle Cross-Origin Resource Sharing (CORS) in order to accept cross-origin AJAX requests. +# Handle Cross-Origin Resource Sharing (CORS) in order to accept cross-origin Ajax requests. # Read more: https://github.com/cyu/rack-cors diff --git a/config/initializers/filter_parameter_logging.rb b/config/initializers/filter_parameter_logging.rb index f5bfa63..f3ab7a9 100644 --- a/config/initializers/filter_parameter_logging.rb +++ b/config/initializers/filter_parameter_logging.rb @@ -2,9 +2,9 @@ # 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 += %i[ passw secret token _key crypt salt certificate otp ssn ] diff --git a/config/initializers/inflections.rb b/config/initializers/inflections.rb index 3da046c..d747ceb 100644 --- a/config/initializers/inflections.rb +++ b/config/initializers/inflections.rb @@ -5,11 +5,18 @@ # Add new inflection rules using the following format. Inflections # 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.uncountable %w[cargo] -end +# ActiveSupport::Inflector.inflections(:en) do |inflect| +# 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.uncountable %w[cargo] +end diff --git a/config/routes.rb b/config/routes.rb index 7100e61..93e67ad 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -26,8 +26,6 @@ end if Rails.env.cypress? - require "cypress/reset" - require "cypress/last_email" get "__cypress__/reset" => Cypress::Reset.new get "__cypress__/last_email" => Cypress::LastEmail.new end diff --git a/tmp/.gitignore b/tmp/.gitignore new file mode 100644 index 0000000..d36f9b6 --- /dev/null +++ b/tmp/.gitignore @@ -0,0 +1 @@ +local_secret.txt