From f10c624c2d987a522c1debc443d313b9d204df9b Mon Sep 17 00:00:00 2001 From: fauno Date: Thu, 24 Mar 2022 21:14:02 -0300 Subject: [PATCH] =?UTF-8?q?actualizaci=C3=B3n=20a=20rails=206?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Gemfile | 14 +- Gemfile.lock | 268 ++++++++++-------- app/controllers/barcas_controller.rb | 2 +- bin/rails | 7 +- bin/rake | 7 +- bin/setup | 11 +- bin/spring | 15 +- config.ru | 1 + config/application.rb | 18 +- config/environments/development.rb | 35 +-- config/environments/production.rb | 65 +++-- config/environments/test.rb | 44 +-- config/initializers/backtrace_silencers.rb | 6 +- .../initializers/filter_parameter_logging.rb | 4 +- .../new_framework_defaults_6_1.rb | 67 +++++ config/initializers/wrap_parameters.rb | 3 +- config/puma.rb | 13 +- config/spring.rb | 7 +- 18 files changed, 350 insertions(+), 237 deletions(-) create mode 100644 config/initializers/new_framework_defaults_6_1.rb diff --git a/Gemfile b/Gemfile index a0f842e..72b4d10 100644 --- a/Gemfile +++ b/Gemfile @@ -4,17 +4,17 @@ source 'https://rubygems.org' git_source(:github) { |repo| "https://github.com/#{repo}.git" } # Bundle edge Rails instead: gem 'rails', github: 'rails/rails' -gem 'rails', '~> 5.2.3' +gem 'rails', '~> 6' # Use sqlite3 as the database for Active Record gem 'sqlite3' # Use Puma as the app server -gem 'puma', '~> 3.11' +gem 'puma' # Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder -gem 'jbuilder', '~> 2.5' +gem 'jbuilder' # Use Redis adapter to run Action Cable in production # gem 'redis', '~> 4.0' # Use ActiveModel has_secure_password -gem 'bcrypt', '~> 3.1.7' +gem 'bcrypt' gem 'sucker_punch' gem 'validate_url' @@ -24,7 +24,7 @@ gem 'webpush' # gem 'mini_magick', '~> 4.8' # Reduces boot times through caching; required in config/boot.rb -gem 'bootsnap', '>= 1.1.0', require: false +gem 'bootsnap', require: false # Use Rack CORS for handling Cross-Origin Resource Sharing (CORS), # making cross-origin AJAX possible @@ -39,7 +39,7 @@ group :development, :test do end group :development do - gem 'listen', '>= 3.0.5', '< 3.2' + gem 'listen' # Spring speeds up development by keeping your application running in # the background. Read more: https://github.com/rails/spring gem 'bcrypt_pbkdf' @@ -51,7 +51,7 @@ group :development do gem 'ed25519' gem 'rubocop-rails' gem 'spring' - gem 'spring-watcher-listen', '~> 2.0.0' + gem 'spring-watcher-listen' gem 'stackprof' gem 'yard' end diff --git a/Gemfile.lock b/Gemfile.lock index c6216fa..1244293 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,69 +1,86 @@ GEM remote: https://rubygems.org/ specs: - actioncable (5.2.5) - actionpack (= 5.2.5) + actioncable (6.1.5) + actionpack (= 6.1.5) + activesupport (= 6.1.5) nio4r (~> 2.0) websocket-driver (>= 0.6.1) - actionmailer (5.2.5) - actionpack (= 5.2.5) - actionview (= 5.2.5) - activejob (= 5.2.5) + actionmailbox (6.1.5) + actionpack (= 6.1.5) + activejob (= 6.1.5) + activerecord (= 6.1.5) + activestorage (= 6.1.5) + activesupport (= 6.1.5) + mail (>= 2.7.1) + actionmailer (6.1.5) + actionpack (= 6.1.5) + actionview (= 6.1.5) + activejob (= 6.1.5) + activesupport (= 6.1.5) mail (~> 2.5, >= 2.5.4) rails-dom-testing (~> 2.0) - actionpack (5.2.5) - actionview (= 5.2.5) - activesupport (= 5.2.5) - rack (~> 2.0, >= 2.0.8) + actionpack (6.1.5) + actionview (= 6.1.5) + activesupport (= 6.1.5) + rack (~> 2.0, >= 2.0.9) rack-test (>= 0.6.3) rails-dom-testing (~> 2.0) - rails-html-sanitizer (~> 1.0, >= 1.0.2) - actionview (5.2.5) - activesupport (= 5.2.5) + rails-html-sanitizer (~> 1.0, >= 1.2.0) + actiontext (6.1.5) + actionpack (= 6.1.5) + activerecord (= 6.1.5) + activestorage (= 6.1.5) + activesupport (= 6.1.5) + nokogiri (>= 1.8.5) + actionview (6.1.5) + activesupport (= 6.1.5) builder (~> 3.1) erubi (~> 1.4) rails-dom-testing (~> 2.0) - rails-html-sanitizer (~> 1.0, >= 1.0.3) - activejob (5.2.5) - activesupport (= 5.2.5) + rails-html-sanitizer (~> 1.1, >= 1.2.0) + activejob (6.1.5) + activesupport (= 6.1.5) globalid (>= 0.3.6) - activemodel (5.2.5) - activesupport (= 5.2.5) - activerecord (5.2.5) - activemodel (= 5.2.5) - activesupport (= 5.2.5) - arel (>= 9.0) - activestorage (5.2.5) - actionpack (= 5.2.5) - activerecord (= 5.2.5) - marcel (~> 1.0.0) - activesupport (5.2.5) + activemodel (6.1.5) + activesupport (= 6.1.5) + activerecord (6.1.5) + activemodel (= 6.1.5) + activesupport (= 6.1.5) + activestorage (6.1.5) + actionpack (= 6.1.5) + activejob (= 6.1.5) + activerecord (= 6.1.5) + activesupport (= 6.1.5) + marcel (~> 1.0) + mini_mime (>= 1.1.0) + activesupport (6.1.5) concurrent-ruby (~> 1.0, >= 1.0.2) - i18n (>= 0.7, < 2) - minitest (~> 5.1) - tzinfo (~> 1.1) + i18n (>= 1.6, < 2) + minitest (>= 5.1) + tzinfo (~> 2.0) + zeitwerk (~> 2.3) airbrussh (1.4.0) sshkit (>= 1.6.1, != 1.7.0) - arel (9.0.0) ast (2.4.2) axiom-types (0.1.1) descendants_tracker (~> 0.0.4) ice_nine (~> 0.11.0) thread_safe (~> 0.3, >= 0.3.1) - bcrypt (3.1.16) + bcrypt (3.1.17) bcrypt_pbkdf (1.1.0) - benchmark-ips (2.8.4) - bootsnap (1.7.3) - msgpack (~> 1.0) + benchmark-ips (2.10.0) + bootsnap (1.11.1) + msgpack (~> 1.2) builder (3.2.4) - capistrano (3.16.0) + capistrano (3.17.0) airbrussh (>= 1.0.0) i18n rake (>= 10.0.0) sshkit (>= 1.9.0) capistrano-bundler (2.0.1) capistrano (~> 3.1) - capistrano-rails (1.6.1) + capistrano-rails (1.6.2) capistrano (~> 3.1) capistrano-bundler (>= 1.1, < 3) capistrano-rbenv (2.2.0) @@ -72,16 +89,16 @@ GEM coderay (1.1.3) coercible (1.0.0) descendants_tracker (~> 0.0.1) - concurrent-ruby (1.1.8) + concurrent-ruby (1.1.10) crass (1.0.6) database_cleaner (2.0.1) database_cleaner-active_record (~> 2.0.0) - database_cleaner-active_record (2.0.0) + database_cleaner-active_record (2.0.1) activerecord (>= 5.a) database_cleaner-core (~> 2.0.0) database_cleaner-core (2.0.1) - dead_end (1.1.6) - derailed_benchmarks (2.0.1) + dead_end (3.1.1) + derailed_benchmarks (2.1.1) benchmark-ips (~> 2) dead_end get_process_mem (~> 0) @@ -95,145 +112,147 @@ GEM thor (>= 0.19, < 2) descendants_tracker (0.0.4) thread_safe (~> 0.3, >= 0.3.1) - ed25519 (1.2.4) + ed25519 (1.3.0) equalizer (0.0.11) erubi (1.10.0) - factory_bot (6.1.0) + factory_bot (6.2.1) activesupport (>= 5.0.0) - factory_bot_rails (6.1.0) - factory_bot (~> 6.1.0) + factory_bot_rails (6.2.0) + factory_bot (~> 6.2.0) railties (>= 5.0.0) - ffi (1.15.0) + ffi (1.15.5) get_process_mem (0.2.7) ffi (~> 1.0) - globalid (0.4.2) - activesupport (>= 4.2.0) + globalid (1.0.0) + activesupport (>= 5.0) heapy (0.2.0) thor hkdf (0.3.0) httpclient (2.8.3) - i18n (1.8.10) + i18n (1.10.0) concurrent-ruby (~> 1.0) ice_nine (0.11.2) - jbuilder (2.11.2) + jbuilder (2.11.5) + actionview (>= 5.0.0) activesupport (>= 5.0.0) - jwt (2.2.2) - listen (3.1.5) - rb-fsevent (~> 0.9, >= 0.9.4) - rb-inotify (~> 0.9, >= 0.9.7) - ruby_dep (~> 1.2) - loofah (2.9.1) + jwt (2.3.0) + listen (3.7.1) + rb-fsevent (~> 0.10, >= 0.10.3) + rb-inotify (~> 0.9, >= 0.9.10) + loofah (2.15.0) crass (~> 1.0.2) nokogiri (>= 1.5.9) mail (2.7.1) mini_mime (>= 0.1.1) - marcel (1.0.1) + marcel (1.0.2) memory_profiler (1.0.0) method_source (1.0.0) mini_histogram (0.3.1) - mini_mime (1.1.0) - mini_portile2 (2.5.0) - minitest (5.14.4) - msgpack (1.4.2) + mini_mime (1.1.2) + mini_portile2 (2.8.0) + minitest (5.15.0) + msgpack (1.4.5) net-scp (3.0.0) net-ssh (>= 2.6.5, < 7.0.0) net-ssh (6.1.0) - nio4r (2.5.7) - nokogiri (1.11.3) - mini_portile2 (~> 2.5.0) + nio4r (2.5.8) + nokogiri (1.13.3) + mini_portile2 (~> 2.8.0) racc (~> 1.4) - parallel (1.20.1) - parser (3.0.1.0) + parallel (1.22.0) + parser (3.1.1.0) ast (~> 2.4.1) - pry (0.14.0) + pry (0.14.1) coderay (~> 1.1) method_source (~> 1.0) public_suffix (4.0.6) - puma (3.12.6) - racc (1.5.2) + puma (5.6.2) + nio4r (~> 2.0) + racc (1.6.0) rack (2.2.3) rack-cors (1.1.1) rack (>= 2.0.0) rack-test (1.1.0) rack (>= 1.0, < 3) - rails (5.2.5) - actioncable (= 5.2.5) - actionmailer (= 5.2.5) - actionpack (= 5.2.5) - actionview (= 5.2.5) - activejob (= 5.2.5) - activemodel (= 5.2.5) - activerecord (= 5.2.5) - activestorage (= 5.2.5) - activesupport (= 5.2.5) - bundler (>= 1.3.0) - railties (= 5.2.5) + rails (6.1.5) + actioncable (= 6.1.5) + actionmailbox (= 6.1.5) + actionmailer (= 6.1.5) + actionpack (= 6.1.5) + actiontext (= 6.1.5) + actionview (= 6.1.5) + activejob (= 6.1.5) + activemodel (= 6.1.5) + activerecord (= 6.1.5) + activestorage (= 6.1.5) + activesupport (= 6.1.5) + bundler (>= 1.15.0) + railties (= 6.1.5) sprockets-rails (>= 2.0.0) rails-dom-testing (2.0.3) activesupport (>= 4.2.0) nokogiri (>= 1.6) - rails-html-sanitizer (1.3.0) + rails-html-sanitizer (1.4.2) loofah (~> 2.3) - railties (5.2.5) - actionpack (= 5.2.5) - activesupport (= 5.2.5) + railties (6.1.5) + actionpack (= 6.1.5) + activesupport (= 6.1.5) method_source - rake (>= 0.8.7) - thor (>= 0.19.0, < 2.0) - rainbow (3.0.0) - rake (13.0.3) - rb-fsevent (0.10.4) + rake (>= 12.2) + thor (~> 1.0) + rainbow (3.1.1) + rake (13.0.6) + rb-fsevent (0.11.1) rb-inotify (0.10.1) ffi (~> 1.0) - regexp_parser (2.1.1) + regexp_parser (2.2.1) rexml (3.2.5) - rubocop (1.12.1) + rubocop (1.26.1) parallel (~> 1.10) - parser (>= 3.0.0.0) + parser (>= 3.1.0.0) rainbow (>= 2.2.2, < 4.0) regexp_parser (>= 1.8, < 3.0) rexml - rubocop-ast (>= 1.2.0, < 2.0) + rubocop-ast (>= 1.16.0, < 2.0) ruby-progressbar (~> 1.7) unicode-display_width (>= 1.4.0, < 3.0) - rubocop-ast (1.4.1) - parser (>= 2.7.1.5) - rubocop-rails (2.9.1) + rubocop-ast (1.16.0) + parser (>= 3.1.1.0) + rubocop-rails (2.14.2) activesupport (>= 4.2.0) rack (>= 1.1) - rubocop (>= 0.90.0, < 2.0) + rubocop (>= 1.7.0, < 2.0) ruby-progressbar (1.11.0) - ruby-statistics (2.1.3) - ruby_dep (1.5.0) + ruby-statistics (3.0.0) spring (2.1.1) spring-watcher-listen (2.0.1) listen (>= 2.7, < 4.0) spring (>= 1.2, < 3.0) - sprockets (4.0.2) + sprockets (4.0.3) concurrent-ruby (~> 1.0) rack (> 1, < 3) - sprockets-rails (3.2.2) - actionpack (>= 4.0) - activesupport (>= 4.0) + sprockets-rails (3.4.2) + actionpack (>= 5.2) + activesupport (>= 5.2) sprockets (>= 3.0.0) sqlite3 (1.4.2) sshkit (1.21.2) net-scp (>= 1.1.2) net-ssh (>= 2.8.0) - stackprof (0.2.16) + stackprof (0.2.19) sucker_punch (3.0.1) concurrent-ruby (~> 1.0) - telegram-bot (0.15.3) - actionpack (>= 4.0, < 6.2) - activesupport (>= 4.0, < 6.2) + telegram-bot (0.15.6) + actionpack (>= 4.0, < 7.1) + activesupport (>= 4.0, < 7.1) httpclient (~> 2.7) - telegram-bot-types (0.6.2) + telegram-bot-types (0.6.3) virtus (~> 1.0) - thor (1.1.0) + thor (1.2.1) thread_safe (0.3.6) - tzinfo (1.2.9) - thread_safe (~> 0.1) - unicode-display_width (2.0.0) + tzinfo (2.0.4) + concurrent-ruby (~> 1.0) + unicode-display_width (2.1.0) validate_url (1.0.13) activemodel (>= 3.0.0) public_suffix @@ -245,18 +264,21 @@ GEM webpush (1.1.0) hkdf (~> 0.2) jwt (~> 2.0) - websocket-driver (0.7.3) + webrick (1.7.0) + websocket-driver (0.7.5) websocket-extensions (>= 0.1.0) websocket-extensions (0.1.5) - yard (0.9.26) + yard (0.9.27) + webrick (~> 1.7.0) + zeitwerk (2.5.4) PLATFORMS ruby DEPENDENCIES - bcrypt (~> 3.1.7) + bcrypt bcrypt_pbkdf - bootsnap (>= 1.1.0) + bootsnap capistrano capistrano-bundler capistrano-rails @@ -265,15 +287,15 @@ DEPENDENCIES derailed_benchmarks ed25519 factory_bot_rails - jbuilder (~> 2.5) - listen (>= 3.0.5, < 3.2) + jbuilder + listen pry - puma (~> 3.11) + puma rack-cors - rails (~> 5.2.3) + rails (~> 6) rubocop-rails spring - spring-watcher-listen (~> 2.0.0) + spring-watcher-listen sqlite3 stackprof sucker_punch @@ -284,4 +306,4 @@ DEPENDENCIES yard BUNDLED WITH - 2.1.4 + 2.2.2 diff --git a/app/controllers/barcas_controller.rb b/app/controllers/barcas_controller.rb index ce5e30d..25c1c2d 100644 --- a/app/controllers/barcas_controller.rb +++ b/app/controllers/barcas_controller.rb @@ -68,7 +68,7 @@ class BarcasController < ApplicationController # Las piratas solo pueden modificar sus propias barcas @barca = current_pirata.barcas.find(params[:id]) - if @barca.update_attributes barca_params + if @barca.update barca_params notify(subject: :update, urgency: :high) render status: :no_content else diff --git a/bin/rails b/bin/rails index 3504c3f..1b0924f 100755 --- a/bin/rails +++ b/bin/rails @@ -1,11 +1,6 @@ #!/usr/bin/env ruby # frozen_string_literal: true - -begin - load File.expand_path('spring', __dir__) -rescue LoadError => e - raise unless e.message.include?('spring') -end +load File.expand_path('spring', __dir__) APP_PATH = File.expand_path('../config/application', __dir__) require_relative '../config/boot' require 'rails/commands' diff --git a/bin/rake b/bin/rake index 1fe6cf0..75fba90 100755 --- a/bin/rake +++ b/bin/rake @@ -1,11 +1,6 @@ #!/usr/bin/env ruby # frozen_string_literal: true - -begin - load File.expand_path('spring', __dir__) -rescue LoadError => e - raise unless e.message.include?('spring') -end +load File.expand_path('spring', __dir__) require_relative '../config/boot' require 'rake' Rake.application.run diff --git a/bin/setup b/bin/setup index f17c566..cfef514 100755 --- a/bin/setup +++ b/bin/setup @@ -1,8 +1,6 @@ #!/usr/bin/env ruby # frozen_string_literal: true - require 'fileutils' -include FileUtils # path to your application root. APP_ROOT = File.expand_path('..', __dir__) @@ -11,8 +9,9 @@ def system!(*args) system(*args) || abort("\n== Command #{args} failed ==") end -chdir APP_ROOT do - # This script is a starting point to setup your application. +FileUtils.chdir APP_ROOT do + # This script is a way to set up or update your development environment automatically. + # 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 ==' @@ -21,11 +20,11 @@ chdir APP_ROOT do # puts "\n== Copying sample files ==" # unless File.exist?('config/database.yml') - # cp 'config/database.yml.sample', 'config/database.yml' + # FileUtils.cp 'config/database.yml.sample', 'config/database.yml' # end puts "\n== Preparing database ==" - system! 'bin/rails db:setup' + system! 'bin/rails db:prepare' puts "\n== Removing old logs and tempfiles ==" system! 'bin/rails log:clear tmp:clear' diff --git a/bin/spring b/bin/spring index 9bd27ec..413f29d 100755 --- a/bin/spring +++ b/bin/spring @@ -1,18 +1,15 @@ #!/usr/bin/env ruby # frozen_string_literal: true - -# This file loads spring without using Bundler, in order to be fast. -# It gets overwritten when you run the `spring binstub` command. - -unless defined?(Spring) - require 'rubygems' +if !defined?(Spring) && [nil, 'development', 'test'].include?(ENV['RAILS_ENV']) + gem 'bundler' require 'bundler' - lockfile = Bundler::LockfileParser.new(Bundler.default_lockfile.read) - spring = lockfile.specs.detect { |spec| spec.name == 'spring' } - if spring + # Load Spring without loading other gems in the Gemfile, for speed. + Bundler.locked_gems&.specs&.find { |spec| spec.name == 'spring' }&.tap do |spring| Gem.use_paths Gem.dir, Bundler.bundle_path.to_s, *Gem.path gem 'spring', spring.version require 'spring/binstub' + rescue Gem::LoadError + # Ignore when Spring is not installed. end end diff --git a/config.ru b/config.ru index 842bccc..6dc8321 100644 --- a/config.ru +++ b/config.ru @@ -5,3 +5,4 @@ require_relative 'config/environment' run Rails.application +Rails.application.load_server diff --git a/config/application.rb b/config/application.rb index 6e33679..ad8383a 100644 --- a/config/application.rb +++ b/config/application.rb @@ -7,7 +7,14 @@ require 'rails' require 'active_model/railtie' require 'active_job/railtie' require 'active_record/railtie' +# require 'active_storage/engine' require 'action_controller/railtie' +# require 'action_mailer/railtie' +# require 'action_mailbox/engine' +# require 'action_text/engine' +# require 'action_view/railtie' +# require 'action_cable/engine' +# require 'sprockets/railtie' require 'rails/test_unit/railtie' # Require the gems listed in Gemfile, including any gems @@ -20,10 +27,13 @@ module MiniloomApi # Initialize configuration defaults for originally generated Rails version. config.load_defaults 5.2 - # Settings in config/environments/* take precedence over those specified here. - # Application configuration can go into files in config/initializers - # -- all .rb files in that directory are automatically loaded after loading - # the framework and any gems in your application. + # Configuration for the application, engines, and railties goes here. + # + # These settings can be overridden in specific environments using the files + # in config/environments, which are processed later. + # + # config.time_zone = 'Central Time (US & Canada)' + # config.eager_load_paths << Rails.root.join('extras') # Only loads a smaller set of middleware suitable for API only apps. # Middleware like session, flash, cookies can be added back manually. diff --git a/config/environments/development.rb b/config/environments/development.rb index 8d43164..43074c8 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -1,5 +1,7 @@ # frozen_string_literal: true +require 'active_support/core_ext/integer/time' + Rails.application.configure do # Settings specified here will take precedence over those in # config/application.rb. @@ -19,8 +21,6 @@ Rails.application.configure do # Enable/disable caching. By default caching is disabled. # Run rails dev:cache to toggle caching. if Rails.root.join('tmp', 'caching-dev.txt').exist? - config.action_controller.perform_caching = true - config.cache_store = :memory_store config.public_file_server.headers = { 'Cache-Control' => "public, max-age=#{2.days.to_i}" @@ -31,29 +31,32 @@ Rails.application.configure do 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 - - # config.action_mailer.perform_caching = false - # 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 # Highlight code that triggered database queries in logs. config.active_record.verbose_query_logs = true - # Raises error for missing translations - # config.action_view.raise_on_missing_translations = true - # Use an evented file watcher to asynchronously detect changes in - # source code, routes, locales, etc. This feature depends on the - # listen gem. + # 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 end diff --git a/config/environments/production.rb b/config/environments/production.rb index 411b77e..07597e2 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -1,5 +1,7 @@ # frozen_string_literal: true +require 'active_support/core_ext/integer/time' + Rails.application.routes.default_url_options[:host] = ENV.fetch('API_HOST', 'api.lumi.partidopirata.com.ar') Rails.application.routes.default_url_options[:protocol] = 'https' @@ -18,7 +20,6 @@ Rails.application.configure do # Full error reports are disabled and caching is turned on. 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 @@ -36,28 +37,19 @@ Rails.application.configure do # 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 - - # 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.*/ ] + # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX # Force all access to the app over SSL, use Strict-Transport-Security, # and use secure cookies. config.force_ssl = true - # Use the lowest log level to ensure availability of diagnostic - # information when problems arise. + # 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 # Prepend all log lines with the following tags. - config.log_tags = [:request_id] + config.log_tags = %i[request_id] # Use a different cache store in production. # config.cache_store = :mem_cache_store @@ -67,20 +59,22 @@ Rails.application.configure do config.active_job.queue_adapter = :sucker_punch config.active_job.queue_name_prefix = "lumi_#{Rails.env}" - # config.action_mailer.perform_caching = false - - # Ignore bad email addresses and do not raise email delivery errors. - # Set this to true and configure the email server for immediate - # delivery to raise delivery errors. - # - # config.action_mailer.raise_delivery_errors = false - - # Enable locale fallbacks for I18n (makes lookups for any locale fall - # back to the I18n.default_locale when a translation cannot be found). + # Enable locale fallbacks for I18n (makes lookups for any locale fall back to + # the I18n.default_locale when a translation cannot be found). config.i18n.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('miniloom')) @@ -93,4 +87,25 @@ Rails.application.configure do # Do not dump schema after migrations. config.active_record.dump_schema_after_migration = false + + # Inserts middleware to perform automatic connection switching. + # The `database_selector` hash is used to pass options to the DatabaseSelector + # middleware. The `delay` is used to determine how long to wait after a write + # to send a subsequent read to the primary. + # + # The `database_resolver` class is used by the middleware to determine which + # database is appropriate to use based on the time delay. + # + # The `database_resolver_context` class is used by the middleware to set + # timestamps for the last write to the primary. The resolver uses the context + # class timestamps to determine how long to wait before reading from the + # replica. + # + # By default Rails will store a last write timestamp in the session. The + # DatabaseSelector middleware is designed as such you can define your own + # strategy for connection switching and pass that into the middleware through + # these configuration options. + # config.active_record.database_selector = { delay: 2.seconds } + # config.active_record.database_resolver = ActiveRecord::Middleware::DatabaseSelector::Resolver + # config.active_record.database_resolver_context = ActiveRecord::Middleware::DatabaseSelector::Resolver::Session end diff --git a/config/environments/test.rb b/config/environments/test.rb index 157d21d..c059158 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -1,14 +1,18 @@ # frozen_string_literal: true +require 'active_support/core_ext/integer/time' + +# The test environment is used exclusively to run your application's +# test suite. You never need to work with it otherwise. Remember that +# your test database is "scratch space" for the test suite and is wiped +# and recreated between test runs. Don't rely on the data there! + Rails.application.configure do # Settings specified here will take precedence over those in # config/application.rb. - # The test environment is used exclusively to run your application's - # test suite. You never need to work with it otherwise. Remember that - # your test database is "scratch space" for the test suite and is wiped - # and recreated between test runs. Don't rely on the data there! - config.cache_classes = true + config.cache_classes = false + config.action_view.cache_template_loading = true # Do not eager load code on boot. This avoids loading your whole # application just for the purpose of running a single test. If you @@ -19,12 +23,14 @@ Rails.application.configure do # 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}" } + config.public_file_server.headers = { + 'Cache-Control' => "public, max-age=#{1.hour.to_i}" + } # Show full error reports and disable caching. 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 @@ -32,20 +38,18 @@ Rails.application.configure do # 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. - # The :test delivery method accumulates sent emails in the - # ActionMailer::Base.deliveries array. - # config.action_mailer.delivery_method = :test - # Print deprecation notices to the stderr. config.active_support.deprecation = :stderr - # Raises error for missing translations - # config.action_view.raise_on_missing_translations = true + # 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 = [] + + # 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 end diff --git a/config/initializers/backtrace_silencers.rb b/config/initializers/backtrace_silencers.rb index dc60ac8..d4f1842 100644 --- a/config/initializers/backtrace_silencers.rb +++ b/config/initializers/backtrace_silencers.rb @@ -7,6 +7,6 @@ # Rails.backtrace_cleaner.add_silencer { |line| line =~ # /my_noisy_library/ } -# You can also remove all the silencers if you're trying to debug a -# problem that might stem from framework code. -# Rails.backtrace_cleaner.remove_silencers! +# You can also remove all the silencers if you're trying to debug a problem that might stem from framework code +# by setting BACKTRACE=1 before calling your invocation, like "BACKTRACE=1 ./bin/rails runner 'MyClass.perform'". +Rails.backtrace_cleaner.remove_silencers! if ENV["BACKTRACE"] diff --git a/config/initializers/filter_parameter_logging.rb b/config/initializers/filter_parameter_logging.rb index 7a4f47b..9f68e0d 100644 --- a/config/initializers/filter_parameter_logging.rb +++ b/config/initializers/filter_parameter_logging.rb @@ -3,4 +3,6 @@ # Be sure to restart your server when you modify this file. # Configure sensitive parameters which will be filtered from the log file. -Rails.application.config.filter_parameters += [:password] +Rails.application.config.filter_parameters += %i[ + password passw secret token _key crypt salt certificate otp ssn +] diff --git a/config/initializers/new_framework_defaults_6_1.rb b/config/initializers/new_framework_defaults_6_1.rb new file mode 100644 index 0000000..9526b83 --- /dev/null +++ b/config/initializers/new_framework_defaults_6_1.rb @@ -0,0 +1,67 @@ +# 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/wrap_parameters.rb b/config/initializers/wrap_parameters.rb index b5fe52c..2f3c0db 100644 --- a/config/initializers/wrap_parameters.rb +++ b/config/initializers/wrap_parameters.rb @@ -5,8 +5,7 @@ # This file contains settings for ActionController::ParamsWrapper which # is enabled by default. -# Enable parameter wrapping for JSON. You can disable this by setting -# :format to an empty array. +# Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array. ActiveSupport.on_load(:action_controller) do wrap_parameters format: [:json] end diff --git a/config/puma.rb b/config/puma.rb index 1934c5e..72faadf 100644 --- a/config/puma.rb +++ b/config/puma.rb @@ -6,8 +6,14 @@ # maximum value specified for Puma. Default is set to 5 threads for # minimum and maximum; this matches the default thread size of Active # Record. -threads_count = ENV.fetch('RAILS_MAX_THREADS') { 5 } -threads threads_count, threads_count +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 + +# Specifies the `worker_timeout` threshold that Puma will use to wait before +# terminating a worker in development environments. +# +worker_timeout 3600 if ENV.fetch('RAILS_ENV', 'development') == 'development' # Specifies the `port` that Puma will listen on to receive requests; # default is 3000. @@ -18,6 +24,9 @@ port ENV.fetch('PORT') { 3000 } # environment ENV.fetch('RAILS_ENV') { 'development' } +# Specifies the `pidfile` that Puma will use. +pidfile ENV.fetch('PIDFILE') { 'tmp/pids/server.pid' } + # Specifies the number of `workers` to boot in clustered mode. Workers # are forked webserver processes. If using threads and workers together # the concurrency of the application would be max `threads` * `workers`. diff --git a/config/spring.rb b/config/spring.rb index c5933e4..899d2d0 100644 --- a/config/spring.rb +++ b/config/spring.rb @@ -1,8 +1,3 @@ # frozen_string_literal: true -%w[ - .ruby-version - .rbenv-vars - tmp/restart.txt - tmp/caching-dev.txt -].each { |path| Spring.watch(path) } +Spring.watch(*%w[.ruby-version .rbenv-vars tmp/restart.txt tmp/caching-dev.txt])