diff --git a/Gemfile b/Gemfile index c4661e77..a8352f83 100644 --- a/Gemfile +++ b/Gemfile @@ -17,7 +17,7 @@ gem 'mutex_m' gem 'oj', '~> 3.13' gem 'pmb-client', '0.1.0', github: 'sanger/pmb-client' gem 'puma' -gem 'rails', '~> 7.0.8', '>= 7.0.8.7' +gem 'rails', '~> 7.1.0' gem 'roo', '~> 2.8.0' gem 'sanger_barcode_format', github: 'sanger/sanger_barcode_format', branch: 'development' gem 'sassc-rails' diff --git a/Gemfile.lock b/Gemfile.lock index 1a039c70..c805e3dd 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -15,72 +15,78 @@ GIT GEM remote: https://rubygems.org/ specs: - actioncable (7.0.10) - actionpack (= 7.0.10) - activesupport (= 7.0.10) + actioncable (7.1.6) + actionpack (= 7.1.6) + activesupport (= 7.1.6) nio4r (~> 2.0) websocket-driver (>= 0.6.1) - actionmailbox (7.0.10) - actionpack (= 7.0.10) - activejob (= 7.0.10) - activerecord (= 7.0.10) - activestorage (= 7.0.10) - activesupport (= 7.0.10) + zeitwerk (~> 2.6) + actionmailbox (7.1.6) + actionpack (= 7.1.6) + activejob (= 7.1.6) + activerecord (= 7.1.6) + activestorage (= 7.1.6) + activesupport (= 7.1.6) mail (>= 2.7.1) net-imap net-pop net-smtp - actionmailer (7.0.10) - actionpack (= 7.0.10) - actionview (= 7.0.10) - activejob (= 7.0.10) - activesupport (= 7.0.10) + actionmailer (7.1.6) + actionpack (= 7.1.6) + actionview (= 7.1.6) + activejob (= 7.1.6) + activesupport (= 7.1.6) mail (~> 2.5, >= 2.5.4) net-imap net-pop net-smtp - rails-dom-testing (~> 2.0) - actionpack (7.0.10) - actionview (= 7.0.10) - activesupport (= 7.0.10) + rails-dom-testing (~> 2.2) + actionpack (7.1.6) + actionview (= 7.1.6) + activesupport (= 7.1.6) + cgi + nokogiri (>= 1.8.5) racc - rack (~> 2.0, >= 2.2.4) + 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.10) - actionpack (= 7.0.10) - activerecord (= 7.0.10) - activestorage (= 7.0.10) - activesupport (= 7.0.10) + rails-dom-testing (~> 2.2) + rails-html-sanitizer (~> 1.6) + actiontext (7.1.6) + actionpack (= 7.1.6) + activerecord (= 7.1.6) + activestorage (= 7.1.6) + activesupport (= 7.1.6) globalid (>= 0.6.0) nokogiri (>= 1.8.5) - actionview (7.0.10) - activesupport (= 7.0.10) + actionview (7.1.6) + activesupport (= 7.1.6) builder (~> 3.1) - erubi (~> 1.4) - rails-dom-testing (~> 2.0) - rails-html-sanitizer (~> 1.1, >= 1.2.0) - activejob (7.0.10) - activesupport (= 7.0.10) + cgi + erubi (~> 1.11) + rails-dom-testing (~> 2.2) + rails-html-sanitizer (~> 1.6) + activejob (7.1.6) + activesupport (= 7.1.6) globalid (>= 0.3.6) - activemodel (7.0.10) - activesupport (= 7.0.10) - activerecord (7.0.10) - activemodel (= 7.0.10) - activesupport (= 7.0.10) - activestorage (7.0.10) - actionpack (= 7.0.10) - activejob (= 7.0.10) - activerecord (= 7.0.10) - activesupport (= 7.0.10) + activemodel (7.1.6) + activesupport (= 7.1.6) + activerecord (7.1.6) + activemodel (= 7.1.6) + activesupport (= 7.1.6) + timeout (>= 0.4.0) + activestorage (7.1.6) + actionpack (= 7.1.6) + activejob (= 7.1.6) + activerecord (= 7.1.6) + activesupport (= 7.1.6) marcel (~> 1.0) - mini_mime (>= 1.1.0) - activesupport (7.0.10) + activesupport (7.1.6) 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) @@ -116,15 +122,18 @@ GEM capybara-selenium (0.0.6) capybara selenium-webdriver + cgi (0.5.1) childprocess (5.1.0) logger (~> 1.5) coderay (1.1.3) concurrent-ruby (1.3.4) + connection_pool (3.0.2) crass (1.0.6) csv (3.3.5) date (3.5.0) docile (1.4.0) drb (2.2.3) + erb (6.0.1) erubi (1.13.1) exception_notification (4.6.0) actionmailer (>= 5.2, < 9) @@ -164,6 +173,12 @@ GEM logger i18n (1.14.8) concurrent-ruby (~> 1.0) + 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) jquery-rails (4.6.1) rails-dom-testing (>= 1, < 3) railties (>= 4.2.0) @@ -201,9 +216,9 @@ GEM method_source (1.1.0) mini_mime (1.1.5) minitest (5.27.0) - minitest-rails (7.0.1) - minitest (~> 5.10) - railties (~> 7.0.0) + minitest-rails (7.1.1) + minitest (~> 5.20) + railties (>= 7.1.0, < 8.0.0) minitest-rails-capybara (0.0.2) capybara minitest-rails @@ -237,33 +252,44 @@ GEM parser (3.3.10.1) ast (~> 2.4.1) racc + pp (0.6.3) + prettyprint + prettyprint (0.2.0) prism (1.9.0) pry (0.14.2) coderay (~> 1.1) method_source (~> 1.0) pry-rails (0.3.11) pry (>= 0.13.0) + psych (5.3.1) + date + stringio public_suffix (6.0.1) puma (7.2.0) nio4r (~> 2.0) racc (1.8.1) rack (2.2.21) + rack-session (1.0.2) + rack (< 3) rack-test (2.2.0) rack (>= 1.3) - rails (7.0.10) - actioncable (= 7.0.10) - actionmailbox (= 7.0.10) - actionmailer (= 7.0.10) - actionpack (= 7.0.10) - actiontext (= 7.0.10) - actionview (= 7.0.10) - activejob (= 7.0.10) - activemodel (= 7.0.10) - activerecord (= 7.0.10) - activestorage (= 7.0.10) - activesupport (= 7.0.10) + rackup (1.0.1) + rack (< 3) + webrick + rails (7.1.6) + actioncable (= 7.1.6) + actionmailbox (= 7.1.6) + actionmailer (= 7.1.6) + actionpack (= 7.1.6) + actiontext (= 7.1.6) + actionview (= 7.1.6) + activejob (= 7.1.6) + activemodel (= 7.1.6) + activerecord (= 7.1.6) + activestorage (= 7.1.6) + activesupport (= 7.1.6) bundler (>= 1.15.0) - railties (= 7.0.10) + railties (= 7.1.6) rails-controller-testing (1.0.5) actionpack (>= 5.0.1.rc1) actionview (>= 5.0.1.rc1) @@ -275,19 +301,28 @@ GEM rails-html-sanitizer (1.6.2) loofah (~> 2.21) 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) - railties (7.0.10) - actionpack (= 7.0.10) - activesupport (= 7.0.10) - method_source + railties (7.1.6) + actionpack (= 7.1.6) + activesupport (= 7.1.6) + cgi + irb + rackup (>= 1.0.0) rake (>= 12.2) - thor (~> 1.0) - zeitwerk (~> 2.5) + thor (~> 1.0, >= 1.2.2) + tsort (>= 0.2) + zeitwerk (~> 2.6) rainbow (3.1.1) rake (13.3.1) rb-fsevent (0.11.2) rb-inotify (0.11.1) ffi (~> 1.0) + rdoc (7.2.0) + erb + psych (>= 4.0.0) + tsort regexp_parser (2.11.3) + reline (0.6.3) + io-console (~> 0.5) rexml (3.4.4) roo (2.8.3) nokogiri (~> 1) @@ -350,12 +385,14 @@ GEM actionpack (>= 6.1) activesupport (>= 6.1) sprockets (>= 3.0.0) + stringio (3.2.0) syslog (0.4.0) logger thor (1.4.0) tilt (2.1.0) timecop (0.9.10) timeout (0.4.4) + tsort (0.2.0) tzinfo (2.0.6) concurrent-ruby (~> 1.0) uglifier (4.2.1) @@ -363,6 +400,7 @@ GEM unicode-display_width (3.2.0) unicode-emoji (~> 4.1) unicode-emoji (4.2.0) + webrick (1.9.2) websocket (1.2.11) websocket-driver (0.8.0) base64 @@ -405,7 +443,7 @@ DEPENDENCIES pmb-client (= 0.1.0)! pry-rails puma - rails (~> 7.0.8, >= 7.0.8.7) + rails (~> 7.1.0) rails-controller-testing roo (~> 2.8.0) rubocop diff --git a/bin/setup b/bin/setup index aacb6b9c..cf2acd18 100755 --- a/bin/setup +++ b/bin/setup @@ -1,28 +1,25 @@ #!/usr/bin/env ruby -require 'fileutils' -include FileUtils +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 -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 ==' - system! 'gem install bundler --conservative' - system('bundle check') || system!('bundle install') - - # Install JavaScript dependencies if using Yarn - # system('bin/yarn') + puts "== Installing dependencies ==" + system! "gem install bundler --conservative" + system("bundle check") || system!("bundle install") 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 b987323b..9217bbd3 100644 --- a/config/application.rb +++ b/config/application.rb @@ -3,9 +3,13 @@ require_relative 'boot' # We don't want ActiveRecord +require 'rails' +# Pick the frameworks you want: +require 'active_model/railtie' +require 'active_job/railtie' require 'action_controller/railtie' require 'action_mailer/railtie' -require 'sprockets/railtie' +require 'action_view/railtie' require 'rails/test_unit/railtie' require './lib/gatekeeper/version' @@ -27,6 +31,26 @@ class Application < Rails::Application # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC. # config.time_zone = 'Central Time (US & Canada)' + # No longer add autoloaded paths into `$LOAD_PATH`. This means that you won't be able + # to manually require files that are managed by the autoloader, which you shouldn't do anyway. + # + # This will reduce the size of the load path, making `require` faster if you don't use bootsnap, or reduce the size + # of the bootsnap cache if you use it. + config.add_autoload_paths_to_load_path = false + + # 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]) + + # 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") + # 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] config.i18n.enforce_available_locales = false diff --git a/config/environments/development.rb b/config/environments/development.rb index 236f3675..0f205cdf 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -1,26 +1,32 @@ # frozen_string_literal: true +require 'active_support/core_ext/integer/time' + require 'pry' Rails.application.configure do # Settings specified here will take precedence over those in config/application.rb. config.secret_key_base = 'example_dev_environment_key' - # In the development environment your application's code is reloaded on - # every request. This slows down response time but is perfect for development + # In the development environment your application's code is reloaded any time + # it changes. This slows down response time but is perfect for development # since you don't have to restart the web server when you make code changes. - config.cache_classes = false + config.enable_reloading = true # Do not eager load code on boot. config.eager_load = false - # Show full error reports and disable caching. + # 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? # rubocop:todo Rails/FilePath + 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 = { @@ -40,9 +46,27 @@ # 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 = [] + + # 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 + # Raises error for missing translations. + config.i18n.raise_on_missing_translations = false + + # 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 + # 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 diff --git a/config/environments/test.rb b/config/environments/test.rb index 85703975..e3dc4f28 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -1,33 +1,43 @@ # 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 + # 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 static asset server for tests with Cache-Control for performance. - config.serve_static_assets = true - config.static_cache_control = 'public, max-age=3600' + # 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}" + } # 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 + 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. @@ -36,6 +46,21 @@ # Print deprecation notices to the stderr. config.active_support.deprecation = :stderr + # 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 + + # Raise error when a before_action's only/except options reference missing actions + config.action_controller.raise_on_missing_callback_actions = true + # Set up the API connection options config.api_connection_options = ActiveSupport::OrderedOptions.new config.api_connection_options.namespace = 'Gatekeeper' diff --git a/config/initializers/content_security_policy.rb b/config/initializers/content_security_policy.rb index 53538c14..35ab3fd6 100644 --- a/config/initializers/content_security_policy.rb +++ b/config/initializers/content_security_policy.rb @@ -18,9 +18,9 @@ # # policy.report_uri "/csp-violation-report-endpoint" # end # -# # Generate session nonces for permitted importmap and inline scripts +# # Generate session nonces for permitted importmap, inline scripts, and inline styles. # config.content_security_policy_nonce_generator = ->(request) { request.session.id.to_s } -# config.content_security_policy_nonce_directives = %w(script-src) +# config.content_security_policy_nonce_directives = %w(script-src style-src) # # # Report violations without enforcing the policy. # # config.content_security_policy_report_only = true diff --git a/config/initializers/filter_parameter_logging.rb b/config/initializers/filter_parameter_logging.rb index 3df77c5b..c416e6a6 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/new_framework_defaults_5_2.rb b/config/initializers/new_framework_defaults_5_2.rb deleted file mode 100644 index c300f213..00000000 --- a/config/initializers/new_framework_defaults_5_2.rb +++ /dev/null @@ -1,40 +0,0 @@ -# frozen_string_literal: true - -# 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_7_0.rb b/config/initializers/new_framework_defaults_7_0.rb deleted file mode 100644 index ce2d234f..00000000 --- a/config/initializers/new_framework_defaults_7_0.rb +++ /dev/null @@ -1,144 +0,0 @@ -# frozen_string_literal: true - -# 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 `