diff --git a/Gemfile b/Gemfile index 391565109..369613d3a 100644 --- a/Gemfile +++ b/Gemfile @@ -9,11 +9,11 @@ gem "react_on_rails", "16.4.0.rc.9" gem "shakapacker", "9.6.1" # Bundle edge Rails instead: gem "rails", github: "rails/rails" -gem "listen" -gem "rails", "~> 8.0" +gem "rails", "~> 8.1.2" gem "pg" +gem "bootsnap", require: false gem "puma" gem "thruster", "~> 0.1" diff --git a/Gemfile.lock b/Gemfile.lock index cc9947747..4ceaaad9f 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,31 +1,31 @@ GEM remote: https://rubygems.org/ specs: - action_text-trix (2.1.15) + action_text-trix (2.1.17) railties - actioncable (8.1.1) - actionpack (= 8.1.1) - activesupport (= 8.1.1) + actioncable (8.1.2) + actionpack (= 8.1.2) + activesupport (= 8.1.2) nio4r (~> 2.0) websocket-driver (>= 0.6.1) zeitwerk (~> 2.6) - actionmailbox (8.1.1) - actionpack (= 8.1.1) - activejob (= 8.1.1) - activerecord (= 8.1.1) - activestorage (= 8.1.1) - activesupport (= 8.1.1) + actionmailbox (8.1.2) + actionpack (= 8.1.2) + activejob (= 8.1.2) + activerecord (= 8.1.2) + activestorage (= 8.1.2) + activesupport (= 8.1.2) mail (>= 2.8.0) - actionmailer (8.1.1) - actionpack (= 8.1.1) - actionview (= 8.1.1) - activejob (= 8.1.1) - activesupport (= 8.1.1) + actionmailer (8.1.2) + actionpack (= 8.1.2) + actionview (= 8.1.2) + activejob (= 8.1.2) + activesupport (= 8.1.2) mail (>= 2.8.0) rails-dom-testing (~> 2.2) - actionpack (8.1.1) - actionview (= 8.1.1) - activesupport (= 8.1.1) + actionpack (8.1.2) + actionview (= 8.1.2) + activesupport (= 8.1.2) nokogiri (>= 1.8.5) rack (>= 2.2.4) rack-session (>= 1.0.1) @@ -33,36 +33,36 @@ GEM rails-dom-testing (~> 2.2) rails-html-sanitizer (~> 1.6) useragent (~> 0.16) - actiontext (8.1.1) + actiontext (8.1.2) action_text-trix (~> 2.1.15) - actionpack (= 8.1.1) - activerecord (= 8.1.1) - activestorage (= 8.1.1) - activesupport (= 8.1.1) + actionpack (= 8.1.2) + activerecord (= 8.1.2) + activestorage (= 8.1.2) + activesupport (= 8.1.2) globalid (>= 0.6.0) nokogiri (>= 1.8.5) - actionview (8.1.1) - activesupport (= 8.1.1) + actionview (8.1.2) + activesupport (= 8.1.2) builder (~> 3.1) erubi (~> 1.11) rails-dom-testing (~> 2.2) rails-html-sanitizer (~> 1.6) - activejob (8.1.1) - activesupport (= 8.1.1) + activejob (8.1.2) + activesupport (= 8.1.2) globalid (>= 0.3.6) - activemodel (8.1.1) - activesupport (= 8.1.1) - activerecord (8.1.1) - activemodel (= 8.1.1) - activesupport (= 8.1.1) + activemodel (8.1.2) + activesupport (= 8.1.2) + activerecord (8.1.2) + activemodel (= 8.1.2) + activesupport (= 8.1.2) timeout (>= 0.4.0) - activestorage (8.1.1) - actionpack (= 8.1.1) - activejob (= 8.1.1) - activerecord (= 8.1.1) - activesupport (= 8.1.1) + activestorage (8.1.2) + actionpack (= 8.1.2) + activejob (= 8.1.2) + activerecord (= 8.1.2) + activesupport (= 8.1.2) marcel (~> 1.0) - activesupport (8.1.1) + activesupport (8.1.2) base64 bigdecimal concurrent-ruby (~> 1.0, >= 1.3.1) @@ -82,10 +82,12 @@ GEM execjs (~> 2) awesome_print (1.9.2) base64 (0.3.0) - bigdecimal (3.3.1) + bigdecimal (4.0.1) bindex (0.8.1) binding_of_caller (1.0.1) debug_inspector (>= 1.2.0) + bootsnap (1.23.0) + msgpack (~> 1.2) builder (3.3.0) byebug (11.1.3) capybara (3.40.0) @@ -111,8 +113,8 @@ GEM coffee-script-source execjs coffee-script-source (1.12.2) - concurrent-ruby (1.3.5) - connection_pool (2.5.5) + concurrent-ruby (1.3.6) + connection_pool (3.0.2) coveralls_reborn (0.25.0) simplecov (>= 0.18.1, < 0.22.0) term-ansicolor (~> 1.6) @@ -125,7 +127,7 @@ GEM activerecord (>= 5.a) database_cleaner-core (~> 2.0.0) database_cleaner-core (2.0.1) - date (3.5.0) + date (3.5.1) debug (1.9.2) irb (~> 1.10) reline (>= 0.3.8) @@ -133,7 +135,7 @@ GEM diff-lcs (1.5.1) docile (1.4.0) drb (2.2.3) - erb (6.0.0) + erb (6.0.2) erubi (1.13.1) erubis (2.7.0) execjs (2.10.0) @@ -150,27 +152,25 @@ GEM railties (>= 3.0.0) globalid (1.3.0) activesupport (>= 6.1) - i18n (1.14.7) + i18n (1.14.8) concurrent-ruby (~> 1.0) interception (0.5) - io-console (0.8.1) - irb (1.15.3) + io-console (0.8.2) + irb (1.17.0) pp (>= 0.6.0) + prism (>= 1.3.0) rdoc (>= 4.0.0) reline (>= 0.4.2) jbuilder (2.12.0) actionview (>= 5.0.0) activesupport (>= 5.0.0) - json (2.16.0) + json (2.19.1) language_server-protocol (3.17.0.5) launchy (3.0.1) addressable (~> 2.8) childprocess (~> 5.0) - listen (3.9.0) - rb-fsevent (~> 0.10, >= 0.10.3) - rb-inotify (~> 0.9, >= 0.9.10) logger (1.7.0) - loofah (2.24.1) + loofah (2.25.1) crass (~> 1.0.2) nokogiri (>= 1.12.0) mail (2.9.0) @@ -183,10 +183,13 @@ GEM matrix (0.4.2) method_source (1.1.0) mini_mime (1.1.5) - minitest (5.26.2) + minitest (6.0.2) + drb (~> 2.0) + prism (~> 1.5) mize (0.4.1) protocol (~> 2.0) - net-imap (0.5.12) + msgpack (1.8.0) + net-imap (0.6.3) date net-protocol net-pop (0.1.2) @@ -196,9 +199,9 @@ GEM net-smtp (0.5.1) net-protocol nio4r (2.7.5) - nokogiri (1.18.10-arm64-darwin) + nokogiri (1.19.1-arm64-darwin) racc (~> 1.4) - nokogiri (1.18.10-x86_64-linux-gnu) + nokogiri (1.19.1-x86_64-linux-gnu) racc (~> 1.4) package_json (0.2.0) parallel (1.27.0) @@ -229,14 +232,14 @@ GEM pry-stack_explorer (0.6.1) binding_of_caller (~> 1.0) pry (~> 0.13) - psych (5.2.6) + psych (5.3.1) date stringio public_suffix (6.0.2) puma (6.4.2) nio4r (~> 2.0) racc (1.8.1) - rack (3.2.4) + rack (3.2.5) rack-proxy (0.7.7) rack rack-session (2.1.1) @@ -244,28 +247,28 @@ GEM rack (>= 3.0.0) rack-test (2.2.0) rack (>= 1.3) - rackup (2.2.1) + rackup (2.3.1) rack (>= 3) - rails (8.1.1) - actioncable (= 8.1.1) - actionmailbox (= 8.1.1) - actionmailer (= 8.1.1) - actionpack (= 8.1.1) - actiontext (= 8.1.1) - actionview (= 8.1.1) - activejob (= 8.1.1) - activemodel (= 8.1.1) - activerecord (= 8.1.1) - activestorage (= 8.1.1) - activesupport (= 8.1.1) + rails (8.1.2) + actioncable (= 8.1.2) + actionmailbox (= 8.1.2) + actionmailer (= 8.1.2) + actionpack (= 8.1.2) + actiontext (= 8.1.2) + actionview (= 8.1.2) + activejob (= 8.1.2) + activemodel (= 8.1.2) + activerecord (= 8.1.2) + activestorage (= 8.1.2) + activesupport (= 8.1.2) bundler (>= 1.15.0) - railties (= 8.1.1) + railties (= 8.1.2) rails-dom-testing (2.3.0) activesupport (>= 5.0.0) minitest nokogiri (>= 1.6) - rails-html-sanitizer (1.6.2) - loofah (~> 2.21) + rails-html-sanitizer (1.7.0) + loofah (~> 2.25) nokogiri (>= 1.15.7, != 1.16.7, != 1.16.6, != 1.16.5, != 1.16.4, != 1.16.3, != 1.16.2, != 1.16.1, != 1.16.0.rc1, != 1.16.0) rails_best_practices (1.23.2) activesupport @@ -275,9 +278,9 @@ GEM json require_all (~> 3.0) ruby-progressbar - railties (8.1.1) - actionpack (= 8.1.1) - activesupport (= 8.1.1) + railties (8.1.2) + actionpack (= 8.1.2) + activesupport (= 8.1.2) irb (~> 1.13) rackup (>= 1.0.0) rake (>= 12.2) @@ -289,7 +292,7 @@ GEM rb-fsevent (0.11.2) rb-inotify (0.11.1) ffi (~> 1.0) - rdoc (6.15.1) + rdoc (7.2.0) erb psych (>= 4.0.0) tsort @@ -408,17 +411,17 @@ GEM sprockets (>= 3.0.0) stimulus-rails (1.3.3) railties (>= 6.0.0) - stringio (3.1.8) + stringio (3.2.0) strscan (3.1.0) sync (0.5.0) term-ansicolor (1.10.2) mize tins (~> 1.0) - thor (1.4.0) + thor (1.5.0) thruster (0.1.16-arm64-darwin) thruster (0.1.16-x86_64-linux) tilt (2.4.0) - timeout (0.4.4) + timeout (0.6.1) tins (1.33.0) bigdecimal sync @@ -448,7 +451,7 @@ GEM xpath (3.2.0) nokogiri (~> 1.8) yard (0.9.36) - zeitwerk (2.7.3) + zeitwerk (2.7.5) PLATFORMS arm64-darwin @@ -459,6 +462,7 @@ PLATFORMS DEPENDENCIES autoprefixer-rails awesome_print + bootsnap capybara capybara-screenshot coffee-rails @@ -470,7 +474,6 @@ DEPENDENCIES generator_spec jbuilder launchy - listen pg pry pry-byebug @@ -479,7 +482,7 @@ DEPENDENCIES pry-rescue pry-stack_explorer puma - rails (~> 8.0) + rails (~> 8.1.2) rails-html-sanitizer rails_best_practices rainbow diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index c07a80a76..35c9fbfa9 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -25,6 +25,7 @@ <%= javascript_pack_tag('data-turbolinks-track': true, defer: true) %> <%= csrf_meta_tags %> + <%= action_cable_meta_tag %> <%= yield :body_content %> diff --git a/bin/ci b/bin/ci new file mode 100755 index 000000000..164263a82 --- /dev/null +++ b/bin/ci @@ -0,0 +1,21 @@ +#!/usr/bin/env ruby +# frozen_string_literal: true + +require "English" +require_relative "../config/ci" + +def run_step(name, command) + puts "\n== #{name} ==" + puts "$ #{command}" + system(command) + return if $CHILD_STATUS.success? + + warn "\nStep failed: #{name}" + exit($CHILD_STATUS.exitstatus || 1) +end + +TutorialCI::STEPS.each do |name, command| + run_step(name, command) +end + +puts "\nAll CI steps passed." diff --git a/bin/rubocop b/bin/rubocop index 40330c0ff..5a2050471 100755 --- a/bin/rubocop +++ b/bin/rubocop @@ -2,7 +2,7 @@ require "rubygems" require "bundler/setup" -# explicit rubocop config increases performance slightly while avoiding config confusion. +# Explicit RuboCop config increases performance slightly while avoiding config confusion. ARGV.unshift("--config", File.expand_path("../.rubocop.yml", __dir__)) load Gem.bin_path("rubocop", "rubocop") diff --git a/client/app/bundles/comments/components/CommentBox/CommentBox.jsx b/client/app/bundles/comments/components/CommentBox/CommentBox.jsx index 3376f74a5..7f954ce1b 100644 --- a/client/app/bundles/comments/components/CommentBox/CommentBox.jsx +++ b/client/app/bundles/comments/components/CommentBox/CommentBox.jsx @@ -4,6 +4,7 @@ import Immutable from 'immutable'; import _ from 'lodash'; import { injectIntl } from 'react-intl'; import BaseComponent from 'libs/components/BaseComponent'; +import actionCableUrl from 'libs/actionCableUrl'; import SelectLanguage from 'libs/i18n/selectLanguage'; import { defaultMessages, defaultLocale } from 'libs/i18n/default'; import CommentForm from './CommentForm/CommentForm'; @@ -34,14 +35,15 @@ class CommentBox extends BaseComponent { subscribeChannel() { const { messageReceived } = this.props.actions; - const protocol = window.location.protocol === 'https:' ? 'wss://' : 'ws://'; - const cableUrl = `${protocol}${window.location.hostname}:${window.location.port}/cable`; - // ActionCable is a global added through webpack.providePlugin - // eslint-disable-next-line no-undef - this.cable = ActionCable.createConsumer(cableUrl); + + // Avoid loading ActionCable during server-side rendering. + // eslint-disable-next-line global-require + const actionCableModule = require('@rails/actioncable'); + const ActionCable = actionCableModule.default || actionCableModule; + this.cable = ActionCable.createConsumer(actionCableUrl()); /* eslint no-console: ["error", { allow: ["log"] }] */ - this.cable.subscriptions.create( + this.subscription = this.cable.subscriptions.create( { channel: 'CommentsChannel' }, { connected: () => { @@ -64,7 +66,8 @@ class CommentBox extends BaseComponent { } componentWillUnmount() { - this.cable.subscriptions.remove({ channel: 'CommentsChannel' }); + this.subscription?.unsubscribe(); + this.cable?.disconnect(); } refreshComments() { diff --git a/client/app/controllers/comments_controller.js b/client/app/controllers/comments_controller.js index 594d43fbc..82a76fda1 100644 --- a/client/app/controllers/comments_controller.js +++ b/client/app/controllers/comments_controller.js @@ -3,6 +3,7 @@ import * as ActionCable from '@rails/actioncable'; import * as marked from 'marked'; import { gfmHeadingId } from 'marked-gfm-heading-id'; import { mangle } from 'marked-mangle'; +import actionCableUrl from 'libs/actionCableUrl'; marked.use(gfmHeadingId()); marked.use(mangle()); @@ -47,12 +48,9 @@ export default class CommentsController extends Controller { connect() { console.log('connected to Stimulus comments_controller'); - const protocol = window.location.protocol === 'https:' ? 'wss://' : 'ws://'; - const cableUrl = `${protocol}${window.location.hostname}:${window.location.port}/cable`; + this.cable = ActionCable.createConsumer(actionCableUrl()); - this.cable = ActionCable.createConsumer(cableUrl); - - this.cable.subscriptions.create('CommentsChannel', { + this.subscription = this.cable.subscriptions.create('CommentsChannel', { connected: () => { console.log('connected to comments channel using Stimulus controller'); }, @@ -66,4 +64,9 @@ export default class CommentsController extends Controller { }, }); } + + disconnect() { + this.subscription?.unsubscribe(); + this.cable?.disconnect(); + } } diff --git a/client/app/libs/actionCableUrl.js b/client/app/libs/actionCableUrl.js new file mode 100644 index 000000000..fabde35ed --- /dev/null +++ b/client/app/libs/actionCableUrl.js @@ -0,0 +1,4 @@ +export default function actionCableUrl() { + const cableMetaTag = document.querySelector("meta[name='action-cable-url']"); + return cableMetaTag ? cableMetaTag.getAttribute('content') : undefined; +} diff --git a/config/application.rb b/config/application.rb index e7f750090..2e2d4a56b 100644 --- a/config/application.rb +++ b/config/application.rb @@ -11,7 +11,7 @@ module RailsReactTutorial class Application < Rails::Application # Initialize configuration defaults for originally generated Rails version. - config.load_defaults 8.0 + config.load_defaults 8.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. @@ -22,8 +22,7 @@ class Application < Rails::Application # # These settings can be overridden in specific environments using the files # in config/environments, which are processed later. - - config.active_support.to_time_preserves_timezone = false + # # config.time_zone = "Central Time (US & Canada)" # config.eager_load_paths << Rails.root.join("extras") end diff --git a/config/boot.rb b/config/boot.rb index c2241d707..aef6d031e 100644 --- a/config/boot.rb +++ b/config/boot.rb @@ -3,3 +3,4 @@ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__) require "bundler/setup" # Set up gems listed in the Gemfile. +require "bootsnap/setup" # Speed up boot time by caching expensive operations. diff --git a/config/ci.rb b/config/ci.rb new file mode 100644 index 000000000..6a4517cf4 --- /dev/null +++ b/config/ci.rb @@ -0,0 +1,17 @@ +# frozen_string_literal: true + +module TutorialCI + STEPS = [ + ["Setup", "bin/conductor-exec bin/setup --skip-server"], + ["Style: Ruby", "bin/conductor-exec bin/rubocop"], + ["Style: JavaScript", "bin/conductor-exec yarn lint:eslint"], + [ + "Build: Test assets", + "RAILS_ENV=test bin/conductor-exec bin/rails react_on_rails:generate_packs && " \ + "bin/conductor-exec yarn res:build && " \ + "bin/conductor-exec yarn build:test" + ], + ["Tests: RSpec", "bin/conductor-exec bin/rspec"], + ["Tests: Jest", "bin/conductor-exec yarn test:client"] + ].freeze +end diff --git a/config/environments/development.rb b/config/environments/development.rb index d7291fd83..6a6e0b625 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -22,11 +22,11 @@ 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}" } + config.cache_store = :memory_store else - config.cache_store = :null_store config.action_controller.perform_caching = false + config.cache_store = :null_store end # Store uploaded files on the local file system (see config/storage.yml for options). @@ -38,15 +38,12 @@ # Make template changes take effect immediately. config.action_mailer.perform_caching = false + # Set localhost to be used by links generated in mailer templates. + config.action_mailer.default_url_options = { host: "localhost", port: 3000 } + # Print deprecation notices to the Rails logger. config.active_support.deprecation = :log - # Raise exceptions for disallowed deprecations. - config.active_support.disallowed_deprecation = :raise - - # Tell Active Support which deprecation messages to disallow. - config.active_support.disallowed_deprecation_warnings = [] - # Raise an error on page load if there are pending migrations. config.active_record.migration_error = :page_load @@ -59,16 +56,15 @@ # Highlight code that enqueued background job in logs. config.active_job.verbose_enqueue_logs = true + # Highlight code that triggered redirect in logs. + config.action_dispatch.verbose_redirect_logs = true + # Raises error for missing translations. # config.i18n.raise_on_missing_translations = true # Annotate rendered view with file names. config.action_view.annotate_rendered_view_with_filenames = true - # Use an evented file watcher to asynchronously detect changes in source code, - # routes, locales, etc. This feature depends on the listen gem. - config.file_watcher = ActiveSupport::EventedFileUpdateChecker - # Uncomment if you wish to allow Action Cable access from any origin. # config.action_cable.disable_request_forgery_protection = true diff --git a/config/environments/production.rb b/config/environments/production.rb index d4c6934a0..7ea9db85d 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -17,12 +17,7 @@ # Turn on fragment caching in view templates. config.action_controller.perform_caching = true - # Ensures that a master key has been made available in either ENV["RAILS_MASTER_KEY"] - # or in config/master.key. This key is used to decrypt credentials (and other encrypted files). - # config.require_master_key = true - - # Disable serving static files from the `/public` folder by default since - # Apache or NGINX already handles this. + # Serve static files if enabled by the environment. config.public_file_server.enabled = ENV["RAILS_SERVE_STATIC_FILES"].present? # Cache assets for far-future expiry since they are all digest stamped. @@ -47,12 +42,15 @@ config.log_tags = [:request_id] config.logger = ActiveSupport::TaggedLogging.logger($stdout) - # Change to "debug" to log everything (including potentially personally-identifiable information!) + # Change to "debug" to log everything (including potentially personally-identifiable information!). config.log_level = ENV.fetch("RAILS_LOG_LEVEL", "info") # Prevent health checks from clogging up the logs. config.silence_healthcheck_path = "/up" + # Keep deprecations visible by default so upgrades don't hide breaking changes. + config.active_support.report_deprecations = ENV["RAILS_REPORT_DEPRECATIONS"] != "false" + # Replace the default in-process memory cache store with a durable alternative. # config.cache_store = :mem_cache_store @@ -66,7 +64,7 @@ # Set host to be used by links generated in mailer templates. # config.action_mailer.default_url_options = { host: "example.com" } - # Specify outgoing SMTP server. Remember to add smtp/* credentials via rails credentials:edit. + # Specify outgoing SMTP server. Remember to add smtp/* credentials via bin/rails credentials:edit. # config.action_mailer.smtp_settings = { # user_name: Rails.application.credentials.dig(:smtp, :user_name), # password: Rails.application.credentials.dig(:smtp, :password), @@ -79,36 +77,11 @@ # the I18n.default_locale when a translation cannot be found). config.i18n.fallbacks = true - # Don't log any deprecations. - # config.active_support.report_deprecations = false - - # 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 - # Do not dump schema after migrations. config.active_record.dump_schema_after_migration = false # Only use :id for inspections in production. - # config.active_record.attributes_for_inspect = [:id] + config.active_record.attributes_for_inspect = [:id] # Enable DNS rebinding protection and other `Host` header attacks. # config.hosts = [ @@ -119,14 +92,10 @@ # Skip DNS rebinding protection for the default health check endpoint. # config.host_authorization = { exclude: ->(request) { request.path == "/up" } } - # 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 - # Action Cable endpoint configuration - - config.action_cable.url = "wss://#{ENV.fetch('PRODUCTION_HOST', nil)}/cable" - config.action_cable.allowed_request_origins = ["https://#{ENV.fetch('PRODUCTION_HOST', nil)}"] + production_host = ENV.fetch("PRODUCTION_HOST", nil) + if production_host.present? + config.action_cable.url = "wss://#{production_host}/cable" + config.action_cable.allowed_request_origins = ["https://#{production_host}"] + end end diff --git a/config/environments/test.rb b/config/environments/test.rb index 012cc3611..3b04bf521 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -39,7 +39,7 @@ config.action_mailer.delivery_method = :test # Set host to be used by links generated in mailer templates. - # config.action_mailer.default_url_options = { host: "example.com" } + config.action_mailer.default_url_options = { host: "example.com" } # Print deprecation notices to the stderr. config.active_support.deprecation = :stderr diff --git a/config/initializers/application_controller_renderer.rb b/config/initializers/application_controller_renderer.rb deleted file mode 100644 index 6d56e4390..000000000 --- a/config/initializers/application_controller_renderer.rb +++ /dev/null @@ -1,10 +0,0 @@ -# frozen_string_literal: true - -# Be sure to restart your server when you modify this file. - -# ActiveSupport::Reloader.to_prepare do -# ApplicationController.renderer.defaults.merge!( -# http_host: 'example.org', -# https: false -# ) -# end diff --git a/config/initializers/content_security_policy.rb b/config/initializers/content_security_policy.rb index 35ab3fd6a..74b18c5a1 100644 --- a/config/initializers/content_security_policy.rb +++ b/config/initializers/content_security_policy.rb @@ -22,6 +22,10 @@ # config.content_security_policy_nonce_generator = ->(request) { request.session.id.to_s } # config.content_security_policy_nonce_directives = %w(script-src style-src) # +# # Automatically add `nonce` to `javascript_tag`, `javascript_include_tag`, and `stylesheet_link_tag` +# # if the corresponding directives are specified in `content_security_policy_nonce_directives`. +# # config.content_security_policy_nonce_auto = true +# # # Report violations without enforcing the policy. # # config.content_security_policy_report_only = true # end diff --git a/config/initializers/cookies_serializer.rb b/config/initializers/cookies_serializer.rb deleted file mode 100644 index ee8dff9c9..000000000 --- a/config/initializers/cookies_serializer.rb +++ /dev/null @@ -1,7 +0,0 @@ -# frozen_string_literal: true - -# Be sure to restart your server when you modify this file. - -# Specify a serializer for the signed and encrypted cookie jars. -# Valid options are :json, :marshal, and :hybrid. -Rails.application.config.action_dispatch.cookies_serializer = :json diff --git a/config/initializers/per_form_csrf_tokens.rb b/config/initializers/per_form_csrf_tokens.rb deleted file mode 100644 index fe50520d0..000000000 --- a/config/initializers/per_form_csrf_tokens.rb +++ /dev/null @@ -1,6 +0,0 @@ -# frozen_string_literal: true - -# Be sure to restart your server when you modify this file. - -# Enable per-form CSRF tokens. -Rails.application.config.action_controller.per_form_csrf_tokens = true diff --git a/config/initializers/request_forgery_protection.rb b/config/initializers/request_forgery_protection.rb deleted file mode 100644 index 0e1994ad2..000000000 --- a/config/initializers/request_forgery_protection.rb +++ /dev/null @@ -1,6 +0,0 @@ -# frozen_string_literal: true - -# Be sure to restart your server when you modify this file. - -# Enable origin-checking CSRF mitigation. -Rails.application.config.action_controller.forgery_protection_origin_check = true diff --git a/config/puma.rb b/config/puma.rb index 80098b36f..97208e2f7 100644 --- a/config/puma.rb +++ b/config/puma.rb @@ -9,7 +9,8 @@ # # You can control the number of workers using ENV["WEB_CONCURRENCY"]. You # should only set this value when you want to run 2 or more workers. The -# default is already 1. +# default is already 1. You can set it to `auto` to automatically start a worker +# for each available processor. # # The ideal number of threads per worker depends both on how much time the # application spends waiting for IO operations and on how much you wish to @@ -20,18 +21,15 @@ # Global VM Lock (GVL) it has diminishing returns and will degrade the # response time (latency) of the application. # -# The default is set to 3 threads as it's deemed a decent compromise between -# throughput and latency for the average Rails application. +# The default is 5 threads in the Rails template. # # Any libraries that use a connection pool or another resource pool should # be configured to provide at least as many connections as the number of # threads. This includes Active Record's `pool` parameter in `database.yml`. -max_threads_count = ENV.fetch("RAILS_MAX_THREADS", 5) -min_threads_count = ENV.fetch("RAILS_MIN_THREADS") { max_threads_count } -threads min_threads_count, max_threads_count +threads_count = ENV.fetch("RAILS_MAX_THREADS", 5) +threads threads_count, threads_count -# Specifies the `worker_timeout` threshold that Puma will use to wait before -# terminating a worker in development environments. +# Allow long-running requests in development (e.g. debugger breakpoints). worker_timeout 3600 if ENV.fetch("RAILS_ENV", "development") == "development" # Specifies the `port` that Puma will listen on to receive requests; default is 3000. @@ -40,12 +38,9 @@ # Allow puma to be restarted by `bin/rails restart` command. plugin :tmp_restart -# Run the Solid Queue supervisor inside of Puma for single-server deployments +# Run the Solid Queue supervisor inside of Puma for single-server deployments. # plugin :solid_queue if ENV["SOLID_QUEUE_IN_PUMA"] -# Specifies the `environment` that Puma will run in. -environment ENV.fetch("RAILS_ENV", "development") - # Specify the PID file. Defaults to tmp/pids/server.pid in development. # In other environments, only set the PID file if requested. pidfile ENV["PIDFILE"] if ENV["PIDFILE"]