From ad6f2849b613da35ac86d3203e0716541ed3d5f1 Mon Sep 17 00:00:00 2001 From: Mark Oveson Date: Sun, 22 Dec 2024 04:07:59 -0700 Subject: [PATCH] Rails 7.1 (Attempt 2) (#1359) * Bump Rails to 7.1 * Remove location_id from split fixtures * Begin working through deprecations and activerecord changes * Remove results_ prefix from relations; get specs passing * Add locals declarations in several views and partial calls * Set config.cache_classes to false as required by Github CI * Set config.enable_reloading to true * Remove old autoload path lib code in favor of config.autoload_lib * Rework core extensions to reconcile class definitions with directory structure * Remove `Extensions` from core ext class names * Require etl/etl in importers * Trying one more thing to make Github CI happy * Define ETL module in etl/etl.rb * Require errors in async importer * Change capitalization of Etl and Html to make zeitwerk happy * Fix module namespacing for UrlHelper monkey patch --- Gemfile | 2 +- Gemfile.lock | 162 +++++----- .../api/v1/event_groups_controller.rb | 4 +- app/controllers/api/v1/events_controller.rb | 6 +- app/controllers/event_groups_controller.rb | 21 +- app/controllers/import_jobs_controller.rb | 4 +- app/controllers/subscriptions_controller.rb | 4 +- app/jobs/import_async_job.rb | 4 +- .../resources/results_category_resource.rb | 4 +- .../results_template_category_resource.rb | 4 +- .../resources/results_template_resource.rb | 4 +- app/models/lottery_division.rb | 10 +- app/models/proto_record.rb | 4 +- app/models/results_category.rb | 4 +- app/models/results_template.rb | 16 +- app/models/results_template_category.rb | 12 +- app/presenters/event_series_presenter.rb | 2 +- app/presenters/podium_presenter.rb | 2 +- app/services/results/compute.rb | 2 +- app/views/courses/index.html.erb | 4 +- app/views/courses/show.html.erb | 2 +- app/views/efforts/_effort_header.html.erb | 2 +- .../efforts/_entrant_for_roster.html.erb | 2 +- app/views/event_groups/_setup_header.html.erb | 4 +- app/views/event_groups/finish_line.html.erb | 2 +- app/views/event_groups/follow.html.erb | 2 +- app/views/event_groups/new.html.erb | 4 +- app/views/event_groups/raw_times.html.erb | 2 +- app/views/event_groups/roster.html.erb | 2 +- .../event_groups/split_raw_times.html.erb | 2 +- app/views/event_groups/stats.html.erb | 2 +- app/views/event_groups/traffic.html.erb | 2 +- app/views/event_groups/webhooks.html.erb | 6 +- app/views/event_series/show.html.erb | 2 +- .../events/_course_setup_splits.html.erb | 2 +- .../events/_time_and_course_info.html.erb | 8 +- app/views/events/_view_buttons.html.erb | 2 + app/views/events/finish_history.html.erb | 2 +- app/views/events/podium.html.erb | 2 +- app/views/events/spread.html.erb | 2 +- app/views/events/summary.html.erb | 2 +- .../_force_pull_times_button.html.erb | 4 +- .../event_groups/_pull_times_button.html.erb | 4 +- .../live/event_groups/live_entry.html.erb | 5 +- app/views/lotteries/draw_tickets.html.erb | 2 +- app/views/lotteries/show.html.erb | 2 +- .../_draw_tickets_header.html.erb | 18 +- .../_tickets_progress_bars.html.erb | 16 +- .../organizations/_organization_tabs.html.erb | 2 +- app/views/organizations/show.html.erb | 4 +- .../_categories_card.html.erb | 4 +- .../_subscriptions_count.html.erb | 4 +- app/views/subscriptions/new.html.erb | 2 +- bin/setup | 2 +- config/application.rb | 22 +- config/environments/development.rb | 8 +- config/environments/production.rb | 44 ++- config/environments/test.rb | 17 +- config/initializers/active_storage.rb | 1 - .../initializers/content_security_policy.rb | 13 +- .../initializers/filter_parameter_logging.rb | 6 +- .../new_framework_defaults_7_0.rb | 117 -------- .../new_framework_defaults_7_1.rb | 280 ++++++++++++++++++ config/initializers/permissions_policy.rb | 20 +- .../action_view/helpers/url_helper.rb | 33 +++ lib/core_ext/array.rb | 62 ++-- lib/core_ext/enumerable.rb | 58 ++-- lib/core_ext/numeric.rb | 26 +- lib/core_ext/string.rb | 33 ++- lib/core_ext/url_helper.rb | 20 -- lib/etl.rb | 34 +++ lib/etl/async_importer.rb | 10 +- lib/etl/csv_templates.rb | 2 +- lib/etl/errors.rb | 2 +- lib/etl/etl.rb | 31 -- lib/etl/event_group_import_process.rb | 2 +- lib/etl/event_import_process.rb | 2 +- lib/etl/extractor.rb | 2 +- .../extractors/adilas_bear_html_strategy.rb | 6 +- lib/etl/extractors/csv_file_strategy.rb | 4 +- .../extractors/its_your_race_html_strategy.rb | 6 +- lib/etl/extractors/pass_through_strategy.rb | 4 +- .../extractors/race_result_api_strategy.rb | 4 +- lib/etl/extractors/race_result_strategy.rb | 4 +- .../helpers/race_result_api_uri_builder.rb | 2 +- lib/etl/helpers/race_result_uri_builder.rb | 2 +- lib/etl/importer.rb | 16 +- lib/etl/importer_from_context.rb | 4 +- lib/etl/loader.rb | 2 +- lib/etl/loaders/async/insert_strategy.rb | 4 +- .../ultrasignup_order_id_compare_strategy.rb | 4 +- lib/etl/loaders/base_loader.rb | 4 +- lib/etl/loaders/insert_strategy.rb | 2 +- lib/etl/loaders/split_time_upsert_strategy.rb | 2 +- lib/etl/loaders/upsert_strategy.rb | 2 +- lib/etl/transformable.rb | 2 +- lib/etl/transformer.rb | 2 +- lib/etl/transformers/adilas_bear_strategy.rb | 2 +- .../async/efforts_with_times_strategy.rb | 4 +- .../hardrock_historical_facts_strategy.rb | 4 +- .../async/historical_facts_strategy.rb | 4 +- lib/etl/transformers/async/null_strategy.rb | 4 +- .../ultrasignup_historical_facts_strategy.rb | 4 +- lib/etl/transformers/base_transformer.rb | 4 +- .../elapsed_incremental_aid_strategy.rb | 2 +- .../event_course_splits_strategy.rb | 2 +- .../event_group_entrants_strategy.rb | 2 +- .../generic_resources_strategy.rb | 2 +- .../transformers/jsonapi_batch_strategy.rb | 2 +- .../transformers/lottery_entrants_strategy.rb | 2 +- .../race_result_api_split_times_strategy.rb | 2 +- .../race_result_entrants_strategy.rb | 2 +- .../race_result_split_times_strategy.rb | 2 +- lib/tasks/pull_event_data.rake | 8 +- .../concerns/prepared_params_spec.rb | 6 +- spec/fixtures/results_template_categories.yml | 216 +++++++------- spec/fixtures/splits.yml | 43 --- spec/lib/etl/async_importer_spec.rb | 4 +- spec/lib/etl/csv_templates_spec.rb | 2 +- .../adilas_bear_html_strategy_spec.rb | 2 +- .../etl/extractors/csv_file_strategy_spec.rb | 4 +- .../its_your_race_html_strategy_spec.rb | 2 +- .../extractors/pass_through_strategy_spec.rb | 4 +- .../race_result_api_strategy_spec.rb | 4 +- .../extractors/race_result_strategy_spec.rb | 4 +- spec/lib/etl/importer_spec.rb | 4 +- .../etl/loaders/async/insert_strategy_spec.rb | 2 +- ...rasignup_order_id_compare_strategy_spec.rb | 2 +- spec/lib/etl/loaders/insert_strategy_spec.rb | 4 +- .../split_time_upsert_strategy_spec.rb | 14 +- spec/lib/etl/loaders/upsert_strategy_spec.rb | 4 +- .../transformers/adilas_bear_strategy_spec.rb | 4 +- .../async/efforts_with_times_strategy_spec.rb | 2 +- ...hardrock_historical_facts_strategy_spec.rb | 2 +- .../async/historical_facts_strategy_spec.rb | 2 +- .../transformers/async/null_strategy_spec.rb | 2 +- ...rasignup_historical_facts_strategy_spec.rb | 2 +- .../elapsed_incremental_aid_strategy_spec.rb | 4 +- .../event_group_entrants_strategy_spec.rb | 2 +- .../generic_resources_strategy_spec.rb | 4 +- .../jsonapi_batch_strategy_spec.rb | 4 +- .../lottery_entrants_strategy_spec.rb | 2 +- ...ce_result_api_split_times_strategy_spec.rb | 2 +- .../race_result_split_times_strategy_spec.rb | 4 +- spec/models/results_template_category_spec.rb | 8 +- spec/models/split_time_spec.rb | 88 +++--- spec/rails_helper.rb | 3 +- 147 files changed, 1035 insertions(+), 794 deletions(-) delete mode 100644 config/initializers/active_storage.rb delete mode 100644 config/initializers/new_framework_defaults_7_0.rb create mode 100644 config/initializers/new_framework_defaults_7_1.rb create mode 100644 lib/core_ext/action_view/helpers/url_helper.rb delete mode 100644 lib/core_ext/url_helper.rb create mode 100644 lib/etl.rb delete mode 100644 lib/etl/etl.rb diff --git a/Gemfile b/Gemfile index cd0bf22e1..969577c94 100644 --- a/Gemfile +++ b/Gemfile @@ -46,7 +46,7 @@ gem "pretender", "~> 0.3", ">= 0.3.4" gem "progress_bar" gem "puma" gem "pundit" -gem "rails", "~> 7.0.0" +gem "rails", "~> 7.1.0" gem "redis", "~> 4.0" gem "rest-client" gem "scenic", ">= 1.5.4" diff --git a/Gemfile.lock b/Gemfile.lock index e452f205e..2e4c13b55 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,51 +1,55 @@ GEM remote: https://rubygems.org/ specs: - actioncable (7.0.8.7) - actionpack (= 7.0.8.7) - activesupport (= 7.0.8.7) + actioncable (7.1.5.1) + actionpack (= 7.1.5.1) + activesupport (= 7.1.5.1) nio4r (~> 2.0) websocket-driver (>= 0.6.1) - actionmailbox (7.0.8.7) - actionpack (= 7.0.8.7) - activejob (= 7.0.8.7) - activerecord (= 7.0.8.7) - activestorage (= 7.0.8.7) - activesupport (= 7.0.8.7) + zeitwerk (~> 2.6) + actionmailbox (7.1.5.1) + actionpack (= 7.1.5.1) + activejob (= 7.1.5.1) + activerecord (= 7.1.5.1) + activestorage (= 7.1.5.1) + activesupport (= 7.1.5.1) mail (>= 2.7.1) net-imap net-pop net-smtp - actionmailer (7.0.8.7) - actionpack (= 7.0.8.7) - actionview (= 7.0.8.7) - activejob (= 7.0.8.7) - activesupport (= 7.0.8.7) + actionmailer (7.1.5.1) + actionpack (= 7.1.5.1) + actionview (= 7.1.5.1) + activejob (= 7.1.5.1) + activesupport (= 7.1.5.1) mail (~> 2.5, >= 2.5.4) net-imap net-pop net-smtp - rails-dom-testing (~> 2.0) - actionpack (7.0.8.7) - actionview (= 7.0.8.7) - activesupport (= 7.0.8.7) - rack (~> 2.0, >= 2.2.4) + rails-dom-testing (~> 2.2) + actionpack (7.1.5.1) + actionview (= 7.1.5.1) + activesupport (= 7.1.5.1) + nokogiri (>= 1.8.5) + racc + rack (>= 2.2.4) + rack-session (>= 1.0.1) rack-test (>= 0.6.3) - rails-dom-testing (~> 2.0) - rails-html-sanitizer (~> 1.0, >= 1.2.0) - actiontext (7.0.8.7) - actionpack (= 7.0.8.7) - activerecord (= 7.0.8.7) - activestorage (= 7.0.8.7) - activesupport (= 7.0.8.7) + rails-dom-testing (~> 2.2) + rails-html-sanitizer (~> 1.6) + actiontext (7.1.5.1) + actionpack (= 7.1.5.1) + activerecord (= 7.1.5.1) + activestorage (= 7.1.5.1) + activesupport (= 7.1.5.1) globalid (>= 0.6.0) nokogiri (>= 1.8.5) - actionview (7.0.8.7) - activesupport (= 7.0.8.7) + actionview (7.1.5.1) + activesupport (= 7.1.5.1) builder (~> 3.1) - erubi (~> 1.4) - rails-dom-testing (~> 2.0) - rails-html-sanitizer (~> 1.1, >= 1.2.0) + erubi (~> 1.11) + rails-dom-testing (~> 2.2) + rails-html-sanitizer (~> 1.6) active_record_query_trace (1.8.2) activerecord (>= 6.0.0) active_storage_validations (1.3.5) @@ -54,27 +58,35 @@ GEM activestorage (>= 6.1.4) activesupport (>= 6.1.4) marcel (>= 1.0.3) - activejob (7.0.8.7) - activesupport (= 7.0.8.7) + activejob (7.1.5.1) + activesupport (= 7.1.5.1) globalid (>= 0.3.6) - activemodel (7.0.8.7) - activesupport (= 7.0.8.7) - activerecord (7.0.8.7) - activemodel (= 7.0.8.7) - activesupport (= 7.0.8.7) + activemodel (7.1.5.1) + activesupport (= 7.1.5.1) + activerecord (7.1.5.1) + activemodel (= 7.1.5.1) + activesupport (= 7.1.5.1) + timeout (>= 0.4.0) activerecord-import (2.0.0) activerecord (>= 4.2) - activestorage (7.0.8.7) - actionpack (= 7.0.8.7) - activejob (= 7.0.8.7) - activerecord (= 7.0.8.7) - activesupport (= 7.0.8.7) + activestorage (7.1.5.1) + actionpack (= 7.1.5.1) + activejob (= 7.1.5.1) + activerecord (= 7.1.5.1) + activesupport (= 7.1.5.1) marcel (~> 1.0) - mini_mime (>= 1.1.0) - activesupport (7.0.8.7) + activesupport (7.1.5.1) + base64 + benchmark (>= 0.3) + bigdecimal concurrent-ruby (~> 1.0, >= 1.0.2) + connection_pool (>= 2.2.5) + drb i18n (>= 1.6, < 2) + logger (>= 1.4.2) minitest (>= 5.1) + mutex_m + securerandom (>= 0.3) tzinfo (~> 2.0) acts_as_list (0.9.19) activerecord (>= 3.0) @@ -131,6 +143,7 @@ GEM aws-eventstream (~> 1, >= 1.0.2) base64 (0.2.0) bcrypt (3.1.20) + benchmark (0.4.0) benchmark-ips (2.14.0) better_errors (2.10.1) erubi (>= 1.0.0) @@ -212,7 +225,7 @@ GEM diff-lcs (1.5.1) domain_name (0.6.20240107) drb (2.2.1) - erubi (1.13.0) + erubi (1.13.1) et-orbi (1.2.11) tzinfo execjs (2.10.0) @@ -259,6 +272,9 @@ GEM mini_magick (>= 4.9.5, < 5) ruby-vips (>= 2.0.17, < 3) io-console (0.8.0) + irb (1.14.3) + rdoc (>= 4.0.0) + reline (>= 0.4.2) jmespath (1.6.2) jsbundling-rails (1.3.1) railties (>= 6.0.0) @@ -303,7 +319,7 @@ GEM activesupport (>= 5.2.0) net-http (0.6.0) uri - net-imap (0.5.2) + net-imap (0.5.3) date net-protocol net-pop (0.1.2) @@ -369,6 +385,9 @@ GEM pry (0.15.0) coderay (~> 1.1) method_source (~> 1.0) + psych (5.2.2) + date + stringio public_suffix (6.0.1) puma (6.5.0) nio4r (~> 2.0) @@ -384,20 +403,23 @@ GEM rack (< 3) rack-test (2.1.0) rack (>= 1.3) - rails (7.0.8.7) - actioncable (= 7.0.8.7) - actionmailbox (= 7.0.8.7) - actionmailer (= 7.0.8.7) - actionpack (= 7.0.8.7) - actiontext (= 7.0.8.7) - actionview (= 7.0.8.7) - activejob (= 7.0.8.7) - activemodel (= 7.0.8.7) - activerecord (= 7.0.8.7) - activestorage (= 7.0.8.7) - activesupport (= 7.0.8.7) + rackup (1.0.1) + rack (< 3) + webrick + rails (7.1.5.1) + actioncable (= 7.1.5.1) + actionmailbox (= 7.1.5.1) + actionmailer (= 7.1.5.1) + actionpack (= 7.1.5.1) + actiontext (= 7.1.5.1) + actionview (= 7.1.5.1) + activejob (= 7.1.5.1) + activemodel (= 7.1.5.1) + activerecord (= 7.1.5.1) + activestorage (= 7.1.5.1) + activesupport (= 7.1.5.1) bundler (>= 1.15.0) - railties (= 7.0.8.7) + railties (= 7.1.5.1) rails-dom-testing (2.2.0) activesupport (>= 5.0.0) minitest @@ -414,18 +436,21 @@ GEM json (>= 1.7, < 3) rails rubyzip (~> 2) - railties (7.0.8.7) - actionpack (= 7.0.8.7) - activesupport (= 7.0.8.7) - method_source + railties (7.1.5.1) + actionpack (= 7.1.5.1) + activesupport (= 7.1.5.1) + irb + rackup (>= 1.0.0) rake (>= 12.2) - thor (~> 1.0) - zeitwerk (~> 2.5) + thor (~> 1.0, >= 1.2.2) + zeitwerk (~> 2.6) rainbow (3.1.1) rake (13.2.1) rb-fsevent (0.11.2) rb-inotify (0.11.1) ffi (~> 1.0) + rdoc (6.10.0) + psych (>= 4.0.0) redis (4.8.1) redis-client (0.23.0) connection_pool @@ -491,6 +516,7 @@ GEM railties (>= 4.0.0) scout_apm (5.4.0) parser + securerandom (0.4.1) selenium-webdriver (4.27.0) base64 (~> 0.2) logger (~> 1.4) @@ -539,6 +565,7 @@ GEM statistics (1.0.0) stimulus-rails (1.3.4) railties (>= 6.0.0) + stringio (3.1.2) strip_attributes (1.14.1) activemodel (>= 3.0, < 9.0) structpluck (0.0.1) @@ -570,6 +597,7 @@ GEM addressable (>= 2.8.0) crack (>= 0.3.2) hashdiff (>= 0.4.0, < 2.0.0) + webrick (1.9.1) websocket (1.2.11) websocket-driver (0.7.6) websocket-extensions (>= 0.1.0) @@ -639,7 +667,7 @@ DEPENDENCIES pry puma pundit - rails (~> 7.0.0) + rails (~> 7.1.0) rails-erd rails_real_favicon (>= 0.1.0) redis (~> 4.0) diff --git a/app/controllers/api/v1/event_groups_controller.rb b/app/controllers/api/v1/event_groups_controller.rb index ea2861f0a..bda2a172d 100644 --- a/app/controllers/api/v1/event_groups_controller.rb +++ b/app/controllers/api/v1/event_groups_controller.rb @@ -19,14 +19,14 @@ def import authorize @resource limited_response = params[:limited_response]&.to_boolean - importer = ::ETL::ImporterFromContext.build(@resource, params, current_user) + importer = ::Etl::ImporterFromContext.build(@resource, params, current_user) importer.import errors = importer.errors + importer.invalid_records.map { |record| jsonapi_error_object(record) } if errors.present? render json: { errors: errors }, status: :unprocessable_entity else - ::ETL::EventGroupImportProcess.perform!(@resource, importer) + ::Etl::EventGroupImportProcess.perform!(@resource, importer) if limited_response render json: {}, status: :created else diff --git a/app/controllers/api/v1/events_controller.rb b/app/controllers/api/v1/events_controller.rb index 6e7713176..8e5235438 100644 --- a/app/controllers/api/v1/events_controller.rb +++ b/app/controllers/api/v1/events_controller.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require "etl/etl" +require "etl" module Api module V1 @@ -53,14 +53,14 @@ def spread end def import - importer = ::ETL::ImporterFromContext.build(@event, params, current_user) + importer = ::Etl::ImporterFromContext.build(@event, params, current_user) importer.import errors = importer.errors + importer.invalid_records.map { |record| jsonapi_error_object(record) } if errors.present? render json: {errors: errors}, status: :unprocessable_entity else - ::ETL::EventImportProcess.perform!(@event, importer) + ::Etl::EventImportProcess.perform!(@event, importer) render json: {}, status: :created end end diff --git a/app/controllers/event_groups_controller.rb b/app/controllers/event_groups_controller.rb index bb9d20586..b1016c070 100644 --- a/app/controllers/event_groups_controller.rb +++ b/app/controllers/event_groups_controller.rb @@ -9,10 +9,10 @@ class EventGroupsController < ApplicationController # GET /event_groups def index scoped_event_groups = policy_scope(EventGroup) - .search(params[:search]) - .by_group_start_time - .preload(:events) - .paginate(page: params[:page], per_page: 25) + .search(params[:search]) + .by_group_start_time + .preload(:events) + .paginate(page: params[:page], per_page: 25) @presenter = EventGroupsCollectionPresenter.new(scoped_event_groups, params, current_user) session[:return_to] = event_groups_path end @@ -113,9 +113,9 @@ def setup_summary # GET /event_groups/1/efforts def efforts @efforts = policy_scope(@event_group.efforts) - .order(prepared_params[:sort] || :bib_number, :last_name, :first_name) - .where(prepared_params[:filter]) - .finish_info_subquery + .order(prepared_params[:sort] || :bib_number, :last_name, :first_name) + .where(prepared_params[:filter]) + .finish_info_subquery render partial: "event_groups/finish_line_effort", locals: { efforts: @efforts } end @@ -437,9 +437,10 @@ def delete_duplicate_raw_times private - def bib_assignment_hash(params_hash) - params_hash.select { |key, _| key.include?("bib_for") } - .transform_keys { |key| key.delete("^0-9").to_i } + def bib_assignment_hash(event_group_params) + event_group_params.to_unsafe_h + .select { |key, _| key.include?("bib_for") } + .transform_keys { |key| key.delete("^0-9").to_i } end def redirect_if_no_events diff --git a/app/controllers/import_jobs_controller.rb b/app/controllers/import_jobs_controller.rb index 21cb71d6b..48481ef5b 100644 --- a/app/controllers/import_jobs_controller.rb +++ b/app/controllers/import_jobs_controller.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require "etl/etl" +require "etl" class ImportJobsController < ApplicationController before_action :authenticate_user! @@ -64,7 +64,7 @@ def csv_templates format.csv do parent = params[:parent_type].constantize.find(params[:parent_id]) import_job_format = params[:import_job_format].to_sym - csv_template_headers = ::ETL::CsvTemplates.headers(import_job_format, parent) + csv_template_headers = ::Etl::CsvTemplates.headers(import_job_format, parent) csv_template = csv_template_headers.join(",") + "\n" filename_components = [import_job_format, parent.class.name.underscore, parent.id, "template.csv"] filename = filename_components.join("_") diff --git a/app/controllers/subscriptions_controller.rb b/app/controllers/subscriptions_controller.rb index bd325c456..7c96dceb3 100644 --- a/app/controllers/subscriptions_controller.rb +++ b/app/controllers/subscriptions_controller.rb @@ -12,6 +12,8 @@ class SubscriptionsController < ApplicationController def new @subscription = @subscribable.subscriptions.new(user: current_user) authorize @subscription + + render :new, locals: { subscription: @subscription } end # POST /subscribable/:subscribable_id/subscriptions @@ -35,7 +37,7 @@ def create render :create, locals: { subscription: @subscription, subscribable: @subscribable, protocol: protocol } else if @subscription.subscribable.is_a?(Event) - render :new, status: :unprocessable_entity + render :new, locals: { subscription: @subscription }, status: :unprocessable_entity else flash.now[:danger] = @subscription.errors.full_messages.to_sentence render turbo_stream: turbo_stream.replace("flash", partial: "layouts/flash") diff --git a/app/jobs/import_async_job.rb b/app/jobs/import_async_job.rb index 8025afaaf..b1c25f43e 100644 --- a/app/jobs/import_async_job.rb +++ b/app/jobs/import_async_job.rb @@ -1,12 +1,12 @@ # frozen_string_literal: true -require "etl/etl" +require "etl" class ImportAsyncJob < ApplicationJob def perform(import_job_id) import_job = ImportJob.find(import_job_id) set_current_user(current_user: import_job.user) - ::ETL::AsyncImporter.import!(import_job) + ::Etl::AsyncImporter.import!(import_job) end end diff --git a/app/madmin/resources/results_category_resource.rb b/app/madmin/resources/results_category_resource.rb index 722ac966a..a31f69c06 100644 --- a/app/madmin/resources/results_category_resource.rb +++ b/app/madmin/resources/results_category_resource.rb @@ -16,8 +16,8 @@ class ResultsCategoryResource < Madmin::Resource # Associations attribute :organization - attribute :results_template_categories - attribute :results_templates + attribute :template_categories + attribute :templates # Uncomment this to customize the display name of records in the admin area. def self.display_name(record) diff --git a/app/madmin/resources/results_template_category_resource.rb b/app/madmin/resources/results_template_category_resource.rb index 16a9e8cdc..2e7a34956 100644 --- a/app/madmin/resources/results_template_category_resource.rb +++ b/app/madmin/resources/results_template_category_resource.rb @@ -7,8 +7,8 @@ class ResultsTemplateCategoryResource < Madmin::Resource attribute :fixed_position # Associations - attribute :results_template - attribute :results_category + attribute :template + attribute :category # Uncomment this to customize the display name of records in the admin area. def self.display_name(record) diff --git a/app/madmin/resources/results_template_resource.rb b/app/madmin/resources/results_template_resource.rb index 54a19a694..65744ae40 100644 --- a/app/madmin/resources/results_template_resource.rb +++ b/app/madmin/resources/results_template_resource.rb @@ -12,8 +12,8 @@ class ResultsTemplateResource < Madmin::Resource # Associations attribute :slugs attribute :organization - attribute :results_template_categories - attribute :results_categories + attribute :template_categories + attribute :categories # Uncomment this to customize the display name of records in the admin area. def self.display_name(record) diff --git a/app/models/lottery_division.rb b/app/models/lottery_division.rb index f0a4a998c..216af1bf9 100644 --- a/app/models/lottery_division.rb +++ b/app/models/lottery_division.rb @@ -63,7 +63,13 @@ def withdrawn_entrants private def broadcast_lottery_draw_header - broadcast_replace_to self, :lottery_draw_header, target: "draw_tickets_header_lottery_division_#{id}", partial: "lottery_divisions/draw_tickets_header", locals: { division: self } - broadcast_replace_to self, :lottery_header, target: "lottery_header_lottery_division_#{id}", partial: "lottery_divisions/tickets_progress_bars", locals: { division: self, show_pre_selected: false } + broadcast_replace_to self, :lottery_draw_header, + target: "draw_tickets_header_lottery_division_#{id}", + partial: "lottery_divisions/draw_tickets_header", + locals: { lottery_division: self } + broadcast_replace_to self, :lottery_header, + target: "lottery_header_lottery_division_#{id}", + partial: "lottery_divisions/tickets_progress_bars", + locals: { lottery_division: self, show_pre_selected: false } end end diff --git a/app/models/proto_record.rb b/app/models/proto_record.rb index c7cd9dead..e81de5518 100644 --- a/app/models/proto_record.rb +++ b/app/models/proto_record.rb @@ -1,10 +1,10 @@ # frozen_string_literal: true -require "etl/etl" +require "etl" require "ostruct" class ProtoRecord - include ETL::Transformable + include Etl::Transformable attr_accessor :record_type, :record_action attr_reader :children, :attributes diff --git a/app/models/results_category.rb b/app/models/results_category.rb index 5cafdf4f2..98f63a4fc 100644 --- a/app/models/results_category.rb +++ b/app/models/results_category.rb @@ -8,8 +8,8 @@ class ResultsCategory < ApplicationRecord friendly_id :organization_genders_ages, use: [:sequentially_slugged, :history] belongs_to :organization, optional: true - has_many :results_template_categories, dependent: :destroy - has_many :results_templates, through: :results_template_categories + has_many :template_categories, dependent: :destroy, class_name: "ResultsTemplateCategory" + has_many :templates, through: :template_categories, class_name: "ResultsTemplate" validates_presence_of :name validates_uniqueness_of :name, scope: :organization diff --git a/app/models/results_template.rb b/app/models/results_template.rb index 684c9bd43..d6a8ce279 100644 --- a/app/models/results_template.rb +++ b/app/models/results_template.rb @@ -7,14 +7,12 @@ class ResultsTemplate < ApplicationRecord friendly_id :name, use: [:slugged, :history] belongs_to :organization, optional: true - has_many :results_template_categories, -> { order(position: :asc) }, dependent: :destroy - has_many :results_categories, through: :results_template_categories - - alias_attribute :categories, :results_categories + has_many :template_categories, -> { order(position: :asc) }, dependent: :destroy, class_name: "ResultsTemplateCategory" + has_many :categories, through: :template_categories, class_name: "ResultsCategory" scope :standard, lambda { select("results_templates.*, count(results_categories.id) as category_count") - .joins(:results_categories).where(organization: nil).group(:id).order("category_count") + .joins(:categories).where(organization: nil).group(:id).order("category_count") } validates_presence_of :name, :aggregation_method @@ -30,21 +28,21 @@ def dup_with_categories set_category_positions template = dup - template.results_categories = results_categories.map(&:dup) + template.categories = categories.map(&:dup) template end # @return [Boolean] def includes_nonbinary? - results_categories.where(nonbinary: true).exists? + categories.where(nonbinary: true).exists? end private def set_category_positions - indexed_rtcs = results_template_categories.index_by(&:results_category_id) + indexed_rtcs = template_categories.index_by(&:results_category_id) - results_categories.each do |rc| + categories.each do |rc| rtc = indexed_rtcs[rc.id] rc.position = rtc.position rc.fixed_position = rtc.fixed_position diff --git a/app/models/results_template_category.rb b/app/models/results_template_category.rb index 546e1f1dd..e39769974 100644 --- a/app/models/results_template_category.rb +++ b/app/models/results_template_category.rb @@ -1,17 +1,17 @@ # frozen_string_literal: true class ResultsTemplateCategory < ApplicationRecord - belongs_to :results_template, optional: false - belongs_to :results_category, optional: false + belongs_to :template, optional: false, class_name: "ResultsTemplate", foreign_key: :results_template_id + belongs_to :category, optional: false, class_name: "ResultsCategory", foreign_key: :results_category_id - acts_as_list scope: :results_template - validates_presence_of :results_category, :results_template + acts_as_list scope: :template + validates_presence_of :category, :template def category_description - results_category.description + category.description end def category_name - results_category.name + category.name end end diff --git a/app/presenters/event_series_presenter.rb b/app/presenters/event_series_presenter.rb index e42227ad4..f4b4a8a02 100644 --- a/app/presenters/event_series_presenter.rb +++ b/app/presenters/event_series_presenter.rb @@ -4,7 +4,7 @@ class EventSeriesPresenter < BasePresenter attr_reader :event_series delegate :name, :organization, :scoring_method, to: :event_series - delegate :results_categories, to: :completed_template + delegate :categories, to: :completed_template def initialize(event_series, view_context) @event_series = event_series || [] diff --git a/app/presenters/podium_presenter.rb b/app/presenters/podium_presenter.rb index ae120df78..c4c910a9e 100644 --- a/app/presenters/podium_presenter.rb +++ b/app/presenters/podium_presenter.rb @@ -16,7 +16,7 @@ def initialize(event, view_context, template:) # @return [Array] def categories - template&.results_categories || [] + template&.categories || [] end # @return [Array] diff --git a/app/services/results/compute.rb b/app/services/results/compute.rb index f27c98ab0..69f162242 100644 --- a/app/services/results/compute.rb +++ b/app/services/results/compute.rb @@ -38,7 +38,7 @@ def point_system end def categories - template.results_categories + template.categories end def fill(category) diff --git a/app/views/courses/index.html.erb b/app/views/courses/index.html.erb index 3bdeabdef..8ce3d8668 100644 --- a/app/views/courses/index.html.erb +++ b/app/views/courses/index.html.erb @@ -7,9 +7,9 @@
- <%= render "organizations/organization_heading", presenter: @presenter %> + <%= render partial: "organizations/organization_heading", locals: { presenter: @presenter } %> - <%= render "organizations/organization_tabs", presenter: @presenter %> + <%= render partial: "organizations/organization_tabs", locals: { presenter: @presenter } %>
diff --git a/app/views/courses/show.html.erb b/app/views/courses/show.html.erb index 9b5469591..688f991e3 100644 --- a/app/views/courses/show.html.erb +++ b/app/views/courses/show.html.erb @@ -48,7 +48,7 @@ <% end %> <% else %> <% if @presenter.events.present? %> - <%= render "events/events", presenter: @presenter, events: @presenter.events, show_grouping_button: false %> + <%= render "events/events", events: @presenter.events %> <% else %>

No events have been held on this course.

<% end %> diff --git a/app/views/efforts/_effort_header.html.erb b/app/views/efforts/_effort_header.html.erb index 3898238c0..662d28724 100644 --- a/app/views/efforts/_effort_header.html.erb +++ b/app/views/efforts/_effort_header.html.erb @@ -1,4 +1,4 @@ -<%# locals: (view_object:) -%> +<%# locals: (view_object:, title: nil) -%>
diff --git a/app/views/efforts/_entrant_for_roster.html.erb b/app/views/efforts/_entrant_for_roster.html.erb index d2e308efd..8da2b1330 100644 --- a/app/views/efforts/_entrant_for_roster.html.erb +++ b/app/views/efforts/_entrant_for_roster.html.erb @@ -1,4 +1,4 @@ -<%# locals: (effort:, multiple_events, :started_efforts_present:) -%> +<%# locals: (effort:, multiple_events:, started_efforts_present:) -%> +<%# locals: (presenter:, breadcrumbs: []) -%>
@@ -25,7 +25,7 @@
- <%= render "event_groups/setup_widget", presenter: presenter %> + <%= render partial: "event_groups/setup_widget", locals: { presenter: presenter } %>
diff --git a/app/views/event_groups/finish_line.html.erb b/app/views/event_groups/finish_line.html.erb index 5e0a1b04e..6888df4e9 100644 --- a/app/views/event_groups/finish_line.html.erb +++ b/app/views/event_groups/finish_line.html.erb @@ -18,7 +18,7 @@
- <%= render "events/time_and_course_info" %> + <%= render partial: "events/time_and_course_info", locals: { presenter: @presenter } %> diff --git a/app/views/event_groups/follow.html.erb b/app/views/event_groups/follow.html.erb index 51294b3ed..da4fefa8c 100644 --- a/app/views/event_groups/follow.html.erb +++ b/app/views/event_groups/follow.html.erb @@ -15,7 +15,7 @@ - <%= render 'events/time_and_course_info' %> + <%= render partial: "events/time_and_course_info", locals: { presenter: @presenter } %> diff --git a/app/views/event_groups/new.html.erb b/app/views/event_groups/new.html.erb index a1db6abd7..619966cd7 100644 --- a/app/views/event_groups/new.html.erb +++ b/app/views/event_groups/new.html.erb @@ -2,8 +2,8 @@ <% "OpenSplitTime: New Event Group" %> <% end %> -<%= render "shared/mode_widget", event_group: @presenter.event_group %> -<%= render "setup_header", presenter: @presenter %> +<%= render partial: "shared/mode_widget", locals: { event_group: @presenter.event_group } %> +<%= render partial: "setup_header", locals: { presenter: @presenter } %>

We will first need some basic information about your Event Group

diff --git a/app/views/event_groups/raw_times.html.erb b/app/views/event_groups/raw_times.html.erb index 7977bc63e..0907a2b49 100644 --- a/app/views/event_groups/raw_times.html.erb +++ b/app/views/event_groups/raw_times.html.erb @@ -16,7 +16,7 @@ - <%= render "events/time_and_course_info" %> + <%= render partial: "events/time_and_course_info", locals: { presenter: @presenter } %> diff --git a/app/views/event_groups/roster.html.erb b/app/views/event_groups/roster.html.erb index 3dfb814fe..a80a6d8a3 100644 --- a/app/views/event_groups/roster.html.erb +++ b/app/views/event_groups/roster.html.erb @@ -20,7 +20,7 @@ - <%= render "events/time_and_course_info" %> + <%= render partial: "events/time_and_course_info", locals: { presenter: @presenter } %> diff --git a/app/views/event_groups/split_raw_times.html.erb b/app/views/event_groups/split_raw_times.html.erb index 610e25fde..819c122ae 100644 --- a/app/views/event_groups/split_raw_times.html.erb +++ b/app/views/event_groups/split_raw_times.html.erb @@ -16,7 +16,7 @@ - <%= render 'events/time_and_course_info' %> + <%= render partial: "events/time_and_course_info", locals: { presenter: @presenter } %> diff --git a/app/views/event_groups/stats.html.erb b/app/views/event_groups/stats.html.erb index 561da0c72..630d74567 100644 --- a/app/views/event_groups/stats.html.erb +++ b/app/views/event_groups/stats.html.erb @@ -17,7 +17,7 @@ - <%= render 'events/time_and_course_info' %> + <%= render partial: "events/time_and_course_info", locals: { presenter: @presenter } %> diff --git a/app/views/event_groups/traffic.html.erb b/app/views/event_groups/traffic.html.erb index b8f172694..4835c7be4 100644 --- a/app/views/event_groups/traffic.html.erb +++ b/app/views/event_groups/traffic.html.erb @@ -16,7 +16,7 @@ - <%= render 'events/time_and_course_info' %> + <%= render partial: "events/time_and_course_info", locals: { presenter: @presenter } %> diff --git a/app/views/event_groups/webhooks.html.erb b/app/views/event_groups/webhooks.html.erb index 11313cc03..c01ed42b8 100644 --- a/app/views/event_groups/webhooks.html.erb +++ b/app/views/event_groups/webhooks.html.erb @@ -15,11 +15,11 @@ - <%= render "events/time_and_course_info" %> + <%= render partial: "events/time_and_course_info", locals: { presenter: @presenter } %> - <%= render "events/view_buttons", view_object: @presenter %> + <%= render partial: "events/view_buttons", locals: { view_object: @presenter } %>
@@ -50,7 +50,7 @@

<%= event.name %> - <%= render "subscriptions/subscriptions_count", subscribable: event, current_user: current_user %> + <%= render partial: "subscriptions/subscriptions_count", locals: { subscribable: event, current_user: current_user } %>

diff --git a/app/views/event_series/show.html.erb b/app/views/event_series/show.html.erb index c56ddb10f..030b03c39 100644 --- a/app/views/event_series/show.html.erb +++ b/app/views/event_series/show.html.erb @@ -40,7 +40,7 @@
- <% @presenter.results_categories.each do |category| %> + <% @presenter.categories.each do |category| %> <% if category.invalid_efforts? %> <%= render 'invalid_results_category', category: category %> <% else %> diff --git a/app/views/events/_course_setup_splits.html.erb b/app/views/events/_course_setup_splits.html.erb index 18de3665e..25fe57efe 100644 --- a/app/views/events/_course_setup_splits.html.erb +++ b/app/views/events/_course_setup_splits.html.erb @@ -1,4 +1,4 @@ -<%# locals: (event:, splits:, aid_stations_by_split_id) -%> +<%# locals: (event:, splits:, aid_stations_by_split_id:) -%>
+
-

<%= l(@presenter.scheduled_start_time_local, format: :full_day_time_and_zone) %> - <% if @presenter.respond_to?(:course) %> - on <%= link_to @presenter.course_name, organization_course_path(@presenter.organization, @presenter.course) %> +

<%= l(presenter.scheduled_start_time_local, format: :full_day_time_and_zone) %> + <% if presenter.respond_to?(:course) %> + on <%= link_to presenter.course_name, organization_course_path(presenter.organization, presenter.course) %> <% end %>

diff --git a/app/views/events/_view_buttons.html.erb b/app/views/events/_view_buttons.html.erb index 7cfbc958a..25164f3d2 100644 --- a/app/views/events/_view_buttons.html.erb +++ b/app/views/events/_view_buttons.html.erb @@ -1,3 +1,5 @@ +<%# locals: (view_object:) %> + - <%= render "time_and_course_info" %> + <%= render partial: "events/time_and_course_info", locals: { presenter: @presenter } %> diff --git a/app/views/events/podium.html.erb b/app/views/events/podium.html.erb index ebdd3c180..d28e5c288 100644 --- a/app/views/events/podium.html.erb +++ b/app/views/events/podium.html.erb @@ -18,7 +18,7 @@ - <%= render "time_and_course_info" %> + <%= render partial: "events/time_and_course_info", locals: { presenter: @presenter } %> diff --git a/app/views/events/spread.html.erb b/app/views/events/spread.html.erb index 09058f12d..450e2b299 100644 --- a/app/views/events/spread.html.erb +++ b/app/views/events/spread.html.erb @@ -18,7 +18,7 @@ - <%= render "time_and_course_info" %> + <%= render partial: "events/time_and_course_info", locals: { presenter: @presenter } %>
- <% template.results_template_categories.includes(:results_category).each do |rtc| %> + <% template.template_categories.includes(:category).each do |rtc| %> @@ -12,7 +12,7 @@ <% end %> - <% if template.results_template_categories.any?(&:fixed_position?) %> + <% if template.template_categories.any?(&:fixed_position?) %> diff --git a/app/views/subscriptions/_subscriptions_count.html.erb b/app/views/subscriptions/_subscriptions_count.html.erb index 446da40fd..e1a864e31 100644 --- a/app/views/subscriptions/_subscriptions_count.html.erb +++ b/app/views/subscriptions/_subscriptions_count.html.erb @@ -1,3 +1,5 @@ <%# locals: (subscribable:, current_user:) %> -<%= "#{pluralize_with_delimiter(subscribable.subscriptions.for_user(current_user).count, 'subscription')}" %> + + <%= "#{pluralize_with_delimiter(subscribable.subscriptions.for_user(current_user).count, 'subscription')}" %> + diff --git a/app/views/subscriptions/new.html.erb b/app/views/subscriptions/new.html.erb index d505e42ec..3517ff0e3 100644 --- a/app/views/subscriptions/new.html.erb +++ b/app/views/subscriptions/new.html.erb @@ -5,5 +5,5 @@ <% end %>
- <%= render "new_modal", subscription: @subscription %> + <%= render partial: "new_modal", locals: { subscription: subscription } %>
diff --git a/bin/setup b/bin/setup index bd1c6e596..2cc479483 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 06e46e1a8..f4a8e7354 100644 --- a/config/application.rb +++ b/config/application.rb @@ -9,8 +9,8 @@ module OpenSplitTime class Application < Rails::Application - # Initialize configuration defaults for a specific Rails version. - config.load_defaults 6.1 + # Initialize configuration defaults for originally generated Rails version. + config.load_defaults 7.1 # Settings in config/environments/* take precedence over those specified here. # Application configuration can go into files in config/initializers @@ -18,17 +18,27 @@ class Application < Rails::Application # the framework and any gems in your application. config.time_zone = "UTC" - config.autoload_paths += %W[#{config.root}/lib] - config.autoload_paths += Dir[File.join(Rails.root, "lib", "core_ext", "**/*.rb")].each { |l| require l } - config.exceptions_app = routes config.action_mailer.delivery_job = "ActionMailer::MailDeliveryJob" config.active_storage.variant_processor = :mini_magick - config.active_support.remove_deprecated_time_with_zone_name = true if ::OstConfig.credentials_env? Rails.application.config.credentials.content_path = ::OstConfig.credentials_content_path end + + # 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.eager_load_paths << Rails.root.join("extras") + + Dir[Rails.root.join('lib/core_ext/**/*.rb')].each { |file| require file } end end diff --git a/config/environments/development.rb b/config/environments/development.rb index b146fda71..da9e996b3 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -7,7 +7,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 @@ -60,6 +60,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 + # Suppress logger output for asset requests. config.assets.quiet = true @@ -75,4 +78,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 74f0405e3..e02cbfca8 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -5,7 +5,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 @@ -27,22 +27,21 @@ } # Full error reports are disabled and caching is turned on. - config.consider_all_requests_local = false + config.consider_all_requests_local = false config.action_controller.perform_caching = true - # Ensures that a master key has been made available in either ENV["RAILS_MASTER_KEY"] - # or in config/master.key. This key is used to decrypt credentials (and other encrypted files). + # Ensures that a master key has been made available in ENV["RAILS_MASTER_KEY"], config/master.key, or an environment + # key such as config/credentials/production.key. This key is used to decrypt credentials (and other encrypted files). config.require_master_key = true - # Disable serving static files from the `/public` folder by default since - # Apache or NGINX already handles this. + # Disable serving static files from `public/`, relying on NGINX/Apache to do so instead. config.public_file_server.enabled = ENV["RAILS_SERVE_STATIC_FILES"].present? # Compress JavaScripts and CSS. config.assets.js_compressor = :terser # config.assets.css_compressor = :sass - # Do not fallback to assets pipeline if a precompiled asset is missed. + # Do not fall back to assets pipeline if a precompiled asset is missed. config.assets.compile = false # Enable serving of images, stylesheets, and JavaScripts from an asset server. @@ -60,6 +59,10 @@ # 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 @@ -122,24 +125,11 @@ config.cache_store = :mem_cache_store, ENV["MEMCACHEDCLOUD_SERVERS"].split(","), {username: ENV["MEMCACHEDCLOUD_USERNAME"], password: ENV["MEMCACHEDCLOUD_PASSWORD"]} end - # Inserts middleware to perform automatic connection switching. - # The `database_selector` hash is used to pass options to the DatabaseSelector - # middleware. The `delay` is used to determine how long to wait after a write - # to send a subsequent read to the primary. - # - # The `database_resolver` class is used by the middleware to determine which - # database is appropriate to use based on the time delay. - # - # The `database_resolver_context` class is used by the middleware to set - # timestamps for the last write to the primary. The resolver uses the context - # class timestamps to determine how long to wait before reading from the - # replica. - # - # By default Rails will store a last write timestamp in the session. The - # DatabaseSelector middleware is designed as such you can define your own - # strategy for connection switching and pass that into the middleware through - # these configuration options. - # config.active_record.database_selector = { delay: 2.seconds } - # config.active_record.database_resolver = ActiveRecord::Middleware::DatabaseSelector::Resolver - # config.active_record.database_resolver_context = ActiveRecord::Middleware::DatabaseSelector::Resolver::Session + # Enable DNS rebinding protection and other `Host` header attacks. + # config.hosts = [ + # "example.com", # Allow requests from example.com + # /.*\.example\.com/ # Allow requests from subdomains like `www.example.com` + # ] + # Skip DNS rebinding protection for the default health check endpoint. + # config.host_authorization = { exclude: ->(request) { request.path == "/up" } } end diff --git a/config/environments/test.rb b/config/environments/test.rb index 19a473849..e7e0ee953 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -8,13 +8,15 @@ 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. + # While tests run files are not watched, reloading is not necessary. config.cache_classes = false + config.enable_reloading = true config.action_view.cache_template_loading = true - # 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. @@ -24,11 +26,11 @@ } # 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. + # Render exception templates for rescuable exceptions and raise for other exceptions. config.action_dispatch.show_exceptions = false # Disable request forgery protection in test environment. @@ -69,4 +71,7 @@ config.active_record.encryption.deterministic_key = "test" config.active_record.encryption.key_derivation_salt = "test" config.active_record.encryption.encrypt_fixtures = 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/initializers/active_storage.rb b/config/initializers/active_storage.rb deleted file mode 100644 index 7cd0727a9..000000000 --- a/config/initializers/active_storage.rb +++ /dev/null @@ -1 +0,0 @@ -Rails.application.config.active_storage.replace_on_assign_to_many = true diff --git a/config/initializers/content_security_policy.rb b/config/initializers/content_security_policy.rb index 3621f97f8..b3076b38f 100644 --- a/config/initializers/content_security_policy.rb +++ b/config/initializers/content_security_policy.rb @@ -1,8 +1,8 @@ # Be sure to restart your server when you modify this file. -# Define an application-wide content security policy -# For further information see the following documentation -# https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy +# Define an application-wide content security policy. +# See the Securing Rails Applications Guide for more information: +# https://guides.rubyonrails.org/security.html#content-security-policy-header # Rails.application.configure do # config.content_security_policy do |policy| @@ -16,11 +16,10 @@ # # 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 CSP violations to a specified URI. See: -# # https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy-Report-Only +# # Report violations without enforcing the policy. # # config.content_security_policy_report_only = true # end diff --git a/config/initializers/filter_parameter_logging.rb b/config/initializers/filter_parameter_logging.rb index 27181055f..c24545e17 100644 --- a/config/initializers/filter_parameter_logging.rb +++ b/config/initializers/filter_parameter_logging.rb @@ -1,8 +1,8 @@ # 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 += [ :passw, :secret, :token, :_key, :crypt, :salt, :certificate, :otp, :ssn, :credentials ] 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 7f16d44fb..000000000 --- a/config/initializers/new_framework_defaults_7_0.rb +++ /dev/null @@ -1,117 +0,0 @@ -# Be sure to restart your server when you modify this file. -# -# This file eases your Rails 7.0 framework defaults upgrade. -# -# Uncomment each configuration one by one to switch to the new default. -# Once your application is ready to run with all new defaults, you can remove -# this file and set the `config.load_defaults` to `7.0`. -# -# Read the Guide for Upgrading Ruby on Rails for more info on each option. -# https://guides.rubyonrails.org/upgrading_ruby_on_rails.html - -# `button_to` view helper will render `
<%= "#{'*' if rtc.fixed_position}" %> <%= "#{rtc.position}." %>
* Position is fixed