From eebd2e380eea35e5c8d8a17897941cbfbda8222d Mon Sep 17 00:00:00 2001 From: Lodewiges Date: Sun, 14 Sep 2025 01:40:22 +0200 Subject: [PATCH 1/8] ran rails app:update --- Gemfile | 2 +- Gemfile.lock | 130 +++++++++--------- bin/brakeman | 7 + bin/rubocop | 8 ++ bin/setup | 32 +++-- config/application.rb | 12 ++ config/environments/development.rb | 82 ++++++----- config/environments/production.rb | 89 ++++++------ config/environments/test.rb | 47 +++++-- config/initializers/assets.rb | 2 +- .../initializers/content_security_policy.rb | 45 +++--- .../initializers/filter_parameter_logging.rb | 8 ++ .../new_framework_defaults_7_2.rb | 70 ++++++++++ config/initializers/permissions_policy.rb | 13 ++ config/puma.rb | 61 ++++---- ..._to_active_storage_blobs.active_storage.rb | 22 +++ ..._storage_variant_records.active_storage.rb | 27 ++++ ...e_storage_blobs_checksum.active_storage.rb | 8 ++ db/schema.rb | 2 +- public/404.html | 67 +++++++++ public/406-unsupported-browser.html | 66 +++++++++ public/422.html | 67 +++++++++ public/500.html | 66 +++++++++ public/icon.png | Bin 0 -> 5599 bytes public/icon.svg | 3 + 25 files changed, 698 insertions(+), 238 deletions(-) create mode 100644 bin/brakeman create mode 100644 bin/rubocop create mode 100644 config/initializers/filter_parameter_logging.rb create mode 100644 config/initializers/new_framework_defaults_7_2.rb create mode 100644 config/initializers/permissions_policy.rb create mode 100644 db/migrate/20250913233759_add_service_name_to_active_storage_blobs.active_storage.rb create mode 100644 db/migrate/20250913233760_create_active_storage_variant_records.active_storage.rb create mode 100644 db/migrate/20250913233761_remove_not_null_on_active_storage_blobs_checksum.active_storage.rb create mode 100644 public/404.html create mode 100644 public/406-unsupported-browser.html create mode 100644 public/422.html create mode 100644 public/500.html create mode 100644 public/icon.png create mode 100644 public/icon.svg diff --git a/Gemfile b/Gemfile index 8a2af6ae6..aa602b934 100644 --- a/Gemfile +++ b/Gemfile @@ -25,7 +25,7 @@ gem 'pg', '~> 1.5.9' gem 'puma', '~> 6.6.0' gem 'pundit', '~> 2.5.0' gem 'rack-attack', '~> 6.7.0' -gem 'rails', '~> 7.1.5', '>= 7.1.5.1' +gem 'rails', '~> 7.2.2', '>= 7.2.2.1' gem 'rails-i18n', '~> 7.0.10' gem 'redis-rails', '~> 5.0.2' gem 'rest-client', '~> 2.1.0' diff --git a/Gemfile.lock b/Gemfile.lock index 35bae8bd3..1198d487b 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,83 +1,77 @@ GEM remote: https://rubygems.org/ specs: - actioncable (7.1.5.1) - actionpack (= 7.1.5.1) - activesupport (= 7.1.5.1) + actioncable (7.2.2.2) + actionpack (= 7.2.2.2) + activesupport (= 7.2.2.2) nio4r (~> 2.0) websocket-driver (>= 0.6.1) 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.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 + actionmailbox (7.2.2.2) + actionpack (= 7.2.2.2) + activejob (= 7.2.2.2) + activerecord (= 7.2.2.2) + activestorage (= 7.2.2.2) + activesupport (= 7.2.2.2) + mail (>= 2.8.0) + actionmailer (7.2.2.2) + actionpack (= 7.2.2.2) + actionview (= 7.2.2.2) + activejob (= 7.2.2.2) + activesupport (= 7.2.2.2) + mail (>= 2.8.0) rails-dom-testing (~> 2.2) - actionpack (7.1.5.1) - actionview (= 7.1.5.1) - activesupport (= 7.1.5.1) + actionpack (7.2.2.2) + actionview (= 7.2.2.2) + activesupport (= 7.2.2.2) nokogiri (>= 1.8.5) racc - rack (>= 2.2.4) + rack (>= 2.2.4, < 3.2) rack-session (>= 1.0.1) rack-test (>= 0.6.3) 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) + useragent (~> 0.16) + actiontext (7.2.2.2) + actionpack (= 7.2.2.2) + activerecord (= 7.2.2.2) + activestorage (= 7.2.2.2) + activesupport (= 7.2.2.2) globalid (>= 0.6.0) nokogiri (>= 1.8.5) - actionview (7.1.5.1) - activesupport (= 7.1.5.1) + actionview (7.2.2.2) + activesupport (= 7.2.2.2) builder (~> 3.1) erubi (~> 1.11) rails-dom-testing (~> 2.2) rails-html-sanitizer (~> 1.6) - activejob (7.1.5.1) - activesupport (= 7.1.5.1) + activejob (7.2.2.2) + activesupport (= 7.2.2.2) globalid (>= 0.3.6) - 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) + activemodel (7.2.2.2) + activesupport (= 7.2.2.2) + activerecord (7.2.2.2) + activemodel (= 7.2.2.2) + activesupport (= 7.2.2.2) timeout (>= 0.4.0) - 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) + activestorage (7.2.2.2) + actionpack (= 7.2.2.2) + activejob (= 7.2.2.2) + activerecord (= 7.2.2.2) + activesupport (= 7.2.2.2) marcel (~> 1.0) - activesupport (7.1.5.1) + activesupport (7.2.2.2) base64 benchmark (>= 0.3) bigdecimal - concurrent-ruby (~> 1.0, >= 1.0.2) + concurrent-ruby (~> 1.0, >= 1.3.1) 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) + tzinfo (~> 2.0, >= 2.0.5) addressable (2.8.7) public_suffix (>= 2.0.2, < 7.0) airbrussh (1.5.3) @@ -264,7 +258,6 @@ GEM msgpack (1.5.2) multi_json (1.15.0) multi_xml (0.6.0) - mutex_m (0.3.0) nenv (0.3.0) date net-protocol @@ -357,20 +350,20 @@ GEM rack (>= 1.3) rackup (2.2.1) rack (>= 3) - 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) + rails (7.2.2.2) + actioncable (= 7.2.2.2) + actionmailbox (= 7.2.2.2) + actionmailer (= 7.2.2.2) + actionpack (= 7.2.2.2) + actiontext (= 7.2.2.2) + actionview (= 7.2.2.2) + activejob (= 7.2.2.2) + activemodel (= 7.2.2.2) + activerecord (= 7.2.2.2) + activestorage (= 7.2.2.2) + activesupport (= 7.2.2.2) bundler (>= 1.15.0) - railties (= 7.1.5.1) + railties (= 7.2.2.2) rails-controller-testing (1.0.5) actionpack (>= 5.0.1.rc1) actionview (>= 5.0.1.rc1) @@ -385,10 +378,10 @@ GEM rails-i18n (7.0.10) i18n (>= 0.7, < 2) railties (>= 6.0.0, < 8) - railties (7.1.5.1) - actionpack (= 7.1.5.1) - activesupport (= 7.1.5.1) - irb + railties (7.2.2.2) + actionpack (= 7.2.2.2) + activesupport (= 7.2.2.2) + irb (~> 1.13) rackup (>= 1.0.0) rake (>= 12.2) thor (~> 1.0, >= 1.2.2) @@ -575,6 +568,7 @@ GEM unicode-emoji (~> 4.0, >= 4.0.4) unicode-emoji (4.0.4) uniform_notifier (1.16.0) + useragent (0.16.11) validates_timeliness (7.1.0) activemodel (>= 7.0.0, < 8) timeliness (>= 0.3.10, < 1) @@ -646,7 +640,7 @@ DEPENDENCIES puma (~> 6.6.0) pundit (~> 2.5.0) rack-attack (~> 6.7.0) - rails (~> 7.1.5, >= 7.1.5.1) + rails (~> 7.2.2, >= 7.2.2.1) rails-controller-testing (~> 1.0.5) rails-i18n (~> 7.0.10) rb-readline (~> 0.5.5) diff --git a/bin/brakeman b/bin/brakeman new file mode 100644 index 000000000..ace1c9ba0 --- /dev/null +++ b/bin/brakeman @@ -0,0 +1,7 @@ +#!/usr/bin/env ruby +require "rubygems" +require "bundler/setup" + +ARGV.unshift("--ensure-latest") + +load Gem.bin_path("brakeman", "brakeman") diff --git a/bin/rubocop b/bin/rubocop new file mode 100644 index 000000000..40330c0ff --- /dev/null +++ b/bin/rubocop @@ -0,0 +1,8 @@ +#!/usr/bin/env ruby +require "rubygems" +require "bundler/setup" + +# explicit rubocop config increases performance slightly while avoiding config confusion. +ARGV.unshift("--config", File.expand_path("../.rubocop.yml", __dir__)) + +load Gem.bin_path("rubocop", "rubocop") diff --git a/bin/setup b/bin/setup index 0e39e8cb1..84e524415 100755 --- a/bin/setup +++ b/bin/setup @@ -1,33 +1,37 @@ #!/usr/bin/env ruby -require 'fileutils' +require "fileutils" -# path to your application root. -APP_ROOT = File.expand_path('..', __dir__) +APP_ROOT = File.expand_path("..", __dir__) +APP_NAME = "sofia" def system!(*args) - system(*args) || abort("\n== Command #{args} failed ==") + system(*args, exception: true) end FileUtils.chdir APP_ROOT do - # This script is a way to setup or update your development environment automatically. - # This script is idempotent, so that you can run it at anytime and get an expectable outcome. + # 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') + puts "== Installing dependencies ==" + system! "gem install bundler --conservative" + system("bundle check") || system!("bundle install") # puts "\n== Copying sample files ==" - # unless File.exist?('config/database.yml') - # FileUtils.cp 'config/database.yml.sample', 'config/database.yml' + # unless File.exist?("config/database.yml") + # FileUtils.cp "config/database.yml.sample", "config/database.yml" # end puts "\n== Preparing database ==" - system! 'bin/rails db:prepare' + system! "bin/rails db:prepare" 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" + + # puts "\n== Configuring puma-dev ==" + # system "ln -nfs #{APP_ROOT} ~/.puma-dev/#{APP_NAME}" + # system "curl -Is https://#{APP_NAME}.test/up | head -n 1" end diff --git a/config/application.rb b/config/application.rb index 1ce3b405b..90967a2de 100644 --- a/config/application.rb +++ b/config/application.rb @@ -2,6 +2,8 @@ require 'rails/all' +# Require the gems listed in Gemfile, including any gems +# you've limited to :test, :development, or :production. Bundler.require(*Rails.groups) module Sofia @@ -9,6 +11,16 @@ class Application < Rails::Application # Initialize configuration defaults for originally generated Rails version. config.load_defaults 7.1 + # Please, add to the `ignore` list any other `lib` subdirectories that do + # not contain `.rb` files, or that should not be reloaded or eager loaded. + # Common ones are `templates`, `generators`, or `middleware`, for example. + config.autoload_lib(ignore: %w[assets tasks]) + + # 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 = 'Europe/Amsterdam' config.generators.javascript_engine = :js diff --git a/config/environments/development.rb b/config/environments/development.rb index e74173158..154bf0af0 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -1,13 +1,16 @@ -Rails.application.configure do - # Verifies that versions and hashed value of the package contents in the project's package.json - config.webpacker.check_yarn_integrity = true +require "active_support/core_ext/integer/time" +Rails.application.configure do # Settings specified here will take precedence over those in config/application.rb. - # In the development environment your application's code is reloaded on - # every request. This slows down response time but is perfect for development + # Verifies that versions and hashed value of the package contents in the + # project's package.json. + config.webpacker.check_yarn_integrity = true + + # 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 @@ -15,16 +18,17 @@ # 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? + if Rails.root.join("tmp/caching-dev.txt").exist? config.action_controller.perform_caching = true config.action_controller.enable_fragment_cache_logging = true config.cache_store = :memory_store - config.public_file_server.headers = { - 'Cache-Control' => "public, max-age=#{2.days.to_i}" - } + config.public_file_server.headers = { "Cache-Control" => "public, max-age=#{2.days.to_i}" } else config.action_controller.perform_caching = false @@ -37,50 +41,62 @@ # Don't care if the mailer can't send. config.action_mailer.raise_delivery_errors = false + # Disable caching for Action Mailer templates even if Action Controller + # caching is enabled. config.action_mailer.perform_caching = false + # Set the default host and port for links in emails to the main Rails app. + config.action_mailer.default_url_options = { host: "localhost", port: 5000 } + + # Set the asset host for images/styles in emails to the Webpacker dev server. + config.action_mailer.asset_host = 'http://localhost:5000' + # 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 - # Debug mode disables concatenation and preprocessing of assets. - # This option may cause significant delays in view rendering with a large - # number of complex assets. - config.assets.debug = 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 + # Enable inline source maps for sass-rails. + config.sass.inline_source_maps = true + # Raises error for missing translations. - # config.action_view.raise_on_missing_translations = true + # config.i18n.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. - config.file_watcher = ActiveSupport::EventedFileUpdateChecker + # Annotate rendered view with file names. + config.action_view.annotate_rendered_view_with_filenames = true - # See https://github.com/sj26/mailcatcher - config.action_mailer.default_url_options = { scheme: 'http', host: 'localhost', port: 5000 } - config.action_mailer.delivery_method = :smtp - config.action_mailer.smtp_settings = { address: 'localhost', port: 1025 } - config.action_mailer.asset_host = 'http://localhost:5000' - config.action_mailer.preview_path = Rails.root.join('spec', 'mailers', 'previews') + # Uncomment if you wish to allow Action Cable access from any origin. + # config.action_cable.disable_request_forgery_protection = true - config.sass.inline_source_maps = true + # Raise error when a before_action's only/except options reference missing actions. + config.action_controller.raise_on_missing_callback_actions = true - config.after_initialize do - Bullet.enable = true - Bullet.console = true - end + # Apply autocorrection by RuboCop to files generated by `bin/rails generate`. + # config.generators.apply_rubocop_autocorrect_after_generate! - # Run Sidekiq inline + # Run Sidekiq jobs immediately in development, instead of queuing them. require 'sidekiq/testing' Sidekiq::Testing.inline! - # Require key to be able to boot - config.require_master_key = true -end + # Configure Bullet to detect N+1 queries. + config.after_initialize do + Bullet.enable = true + Bullet.console = true # Log alerts to the browser console + end +end \ No newline at end of file diff --git a/config/environments/production.rb b/config/environments/production.rb index 6ade5d8ed..738b0cf68 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -1,3 +1,5 @@ +require 'active_support/core_ext/integer/time' + Rails.application.configure do # Verifies that versions and hashed value of the package contents in the project's package.json config.webpacker.check_yarn_integrity = false @@ -5,7 +7,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 @@ -14,25 +16,24 @@ config.eager_load = true # 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 = true # Compress CSS using a preprocessor. # 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. - # config.action_controller.asset_host = 'http://assets.example.com' + # config.asset_host = "http://assets.example.com" # Specifies the header that your server uses for sending files. # config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache @@ -46,23 +47,38 @@ # config.action_cable.url = 'wss://example.com/cable' # config.action_cable.allowed_request_origins = [ 'http://example.com', /http:\/\/example.*/ ] + # Assume all access to the app is happening through a SSL-terminating reverse proxy. + # Can be used together with config.force_ssl for Strict-Transport-Security and secure cookies. + # config.assume_ssl = true + # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. - # config.force_ssl = true + config.force_ssl = true - # Use the lowest log level to ensure availability of diagnostic information - # when problems arise. - config.log_level = :debug + # Skip http-to-https redirect for the default health check endpoint. + # config.ssl_options = { redirect: { exclude: ->(request) { request.path == "/up" } } } + + # Log to STDOUT by default ++ config.logger = ActiveSupport::Logger.new(STDOUT) ++ .tap { |logger| logger.formatter = ::Logger::Formatter.new } ++ .then { |logger| ActiveSupport::TaggedLogging.new(logger) } # Prepend all log lines with the following tags. config.log_tags = [:request_id] + # "info" includes generic and useful information about system operation, but avoids logging too much + # information to avoid inadvertent exposure of personally identifiable information (PII). If you + # want to log everything, set the level to "debug". + config.log_level = ENV.fetch("RAILS_LOG_LEVEL", "info") + # Use a different cache store in production. # config.cache_store = :mem_cache_store # Use a real queuing backend for Active Job (and separate queues per environment). - # config.active_job.queue_adapter = :resque + # config.active_job.queue_adapter = :resque # config.active_job.queue_name_prefix = "sofia_production" + # Disable caching for Action Mailer templates even if Action Controller + # caching is enabled. config.action_mailer.perform_caching = false # Ignore bad email addresses and do not raise email delivery errors. @@ -73,15 +89,8 @@ # 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 - - # Use default logging formatter so that PID and timestamp are not suppressed. - config.log_formatter = Logger::Formatter.new - - # Use a different logger for distributed setups. - # require 'syslog/logger' - # config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name') + # Don't log any deprecations. + config.active_support.report_deprecations = false config.action_mailer.default_url_options = { scheme: 'https', host: Rails.application.config.x.sofia_host @@ -96,33 +105,17 @@ port: 587 } - if ENV['RAILS_LOG_TO_STDOUT'].present? - logger = ActiveSupport::Logger.new($stdout) - logger.formatter = config.log_formatter - config.logger = ActiveSupport::TaggedLogging.new(logger) - end - # Do not dump schema after migrations. config.active_record.dump_schema_after_migration = false - # 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 + # Only use :id for inspections in production. + config.active_record.attributes_for_inspect = [ :id ] + + # 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 70a43ab4d..02320f244 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -1,3 +1,5 @@ +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 @@ -6,26 +8,25 @@ Rails.application.configure do # Settings specified here will take precedence over those in config/application.rb. - config.cache_classes = false + # 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 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.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 @@ -33,6 +34,8 @@ # Store uploaded files on the local file system in a temporary directory. config.active_storage.service = :test + # Disable caching for Action Mailer templates even if Action Controller + # caching is enabled. config.action_mailer.perform_caching = false # Tell Action Mailer not to deliver emails to the real world. @@ -40,6 +43,10 @@ # ActionMailer::Base.deliveries array. config.action_mailer.delivery_method = :test + # Unlike controllers, the mailer instance doesn't have any context about the + # incoming request so you'll need to provide the :host parameter yourself. + config.action_mailer.default_url_options = { host: "www.example.com" } + # Print deprecation notices to the stderr. config.active_support.deprecation = :stderr @@ -55,6 +62,18 @@ Bullet.raise = true end - # 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 + + # 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/assets.rb b/config/initializers/assets.rb index 04d082007..d0e259b6a 100644 --- a/config/initializers/assets.rb +++ b/config/initializers/assets.rb @@ -14,4 +14,4 @@ # Precompile additional assets. # application.js, application.css, and all non-JS/CSS in the app/assets # folder are already added. -# Rails.application.config.assets.precompile += %w( admin.js admin.css ) +# Rails.application.config.assets.precompile += %w[ admin.js admin.css ] diff --git a/config/initializers/content_security_policy.rb b/config/initializers/content_security_policy.rb index 41c43016f..b3076b38f 100644 --- a/config/initializers/content_security_policy.rb +++ b/config/initializers/content_security_policy.rb @@ -1,28 +1,25 @@ # 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.config.content_security_policy do |policy| -# policy.default_src :self, :https -# policy.font_src :self, :https, :data -# policy.img_src :self, :https, :data -# policy.object_src :none -# policy.script_src :self, :https -# policy.style_src :self, :https - -# # Specify URI for violation reports -# # policy.report_uri "/csp-violation-report-endpoint" +# Rails.application.configure do +# config.content_security_policy do |policy| +# policy.default_src :self, :https +# policy.font_src :self, :https, :data +# policy.img_src :self, :https, :data +# policy.object_src :none +# policy.script_src :self, :https +# policy.style_src :self, :https +# # Specify URI for violation reports +# # policy.report_uri "/csp-violation-report-endpoint" +# end +# +# # 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 style-src) +# +# # Report violations without enforcing the policy. +# # config.content_security_policy_report_only = true # end - -# If you are using UJS then enable automatic nonce generation -# Rails.application.config.content_security_policy_nonce_generator = -> request { SecureRandom.base64(16) } - -# Set the nonce only to specific directives -# Rails.application.config.content_security_policy_nonce_directives = %w(script-src) - -# Report CSP violations to a specified URI -# For further information see the following documentation: -# https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy-Report-Only -# Rails.application.config.content_security_policy_report_only = true diff --git a/config/initializers/filter_parameter_logging.rb b/config/initializers/filter_parameter_logging.rb new file mode 100644 index 000000000..c010b83dd --- /dev/null +++ b/config/initializers/filter_parameter_logging.rb @@ -0,0 +1,8 @@ +# Be sure to restart your server when you modify this file. + +# 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, :email, :secret, :token, :_key, :crypt, :salt, :certificate, :otp, :ssn +] diff --git a/config/initializers/new_framework_defaults_7_2.rb b/config/initializers/new_framework_defaults_7_2.rb new file mode 100644 index 000000000..b549c4a25 --- /dev/null +++ b/config/initializers/new_framework_defaults_7_2.rb @@ -0,0 +1,70 @@ +# Be sure to restart your server when you modify this file. +# +# This file eases your Rails 7.2 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.2`. +# +# Read the Guide for Upgrading Ruby on Rails for more info on each option. +# https://guides.rubyonrails.org/upgrading_ruby_on_rails.html + +### +# Controls whether Active Job's `#perform_later` and similar methods automatically defer +# the job queuing to after the current Active Record transaction is committed. +# +# Example: +# Topic.transaction do +# topic = Topic.create(...) +# NewTopicNotificationJob.perform_later(topic) +# end +# +# In this example, if the configuration is set to `:never`, the job will +# be enqueued immediately, even though the `Topic` hasn't been committed yet. +# Because of this, if the job is picked up almost immediately, or if the +# transaction doesn't succeed for some reason, the job will fail to find this +# topic in the database. +# +# If `enqueue_after_transaction_commit` is set to `:default`, the queue adapter +# will define the behaviour. +# +# Note: Active Job backends can disable this feature. This is generally done by +# backends that use the same database as Active Record as a queue, hence they +# don't need this feature. +#++ +# Rails.application.config.active_job.enqueue_after_transaction_commit = :default + +### +# Adds image/webp to the list of content types Active Storage considers as an image +# Prevents automatic conversion to a fallback PNG, and assumes clients support WebP, as they support gif, jpeg, and png. +# This is possible due to broad browser support for WebP, but older browsers and email clients may still not support +# WebP. Requires imagemagick/libvips built with WebP support. +#++ +# Rails.application.config.active_storage.web_image_content_types = %w[image/png image/jpeg image/gif image/webp] + +### +# Enable validation of migration timestamps. When set, an ActiveRecord::InvalidMigrationTimestampError +# will be raised if the timestamp prefix for a migration is more than a day ahead of the timestamp +# associated with the current time. This is done to prevent forward-dating of migration files, which can +# impact migration generation and other migration commands. +# +# Applications with existing timestamped migrations that do not adhere to the +# expected format can disable validation by setting this config to `false`. +#++ +# Rails.application.config.active_record.validate_migration_timestamps = true + +### +# Controls whether the PostgresqlAdapter should decode dates automatically with manual queries. +# +# Example: +# ActiveRecord::ConnectionAdapters::PostgreSQLAdapter.select_value("select '2024-01-01'::date") #=> Date +# +# This query used to return a `String`. +#++ +# Rails.application.config.active_record.postgresql_adapter_decode_dates = true + +### +# Enables YJIT as of Ruby 3.3, to bring sizeable performance improvements. If you are +# deploying to a memory constrained environment you may want to set this to `false`. +#++ +# Rails.application.config.yjit = true diff --git a/config/initializers/permissions_policy.rb b/config/initializers/permissions_policy.rb new file mode 100644 index 000000000..7db3b9577 --- /dev/null +++ b/config/initializers/permissions_policy.rb @@ -0,0 +1,13 @@ +# Be sure to restart your server when you modify this file. + +# Define an application-wide HTTP permissions policy. For further +# information see: https://developers.google.com/web/updates/2018/06/feature-policy + +# Rails.application.config.permissions_policy do |policy| +# policy.camera :none +# policy.gyroscope :none +# policy.microphone :none +# policy.usb :none +# policy.fullscreen :self +# policy.payment :self, "https://secure.example.com" +# end diff --git a/config/puma.rb b/config/puma.rb index 47e2bcf87..8d6c2c360 100644 --- a/config/puma.rb +++ b/config/puma.rb @@ -1,41 +1,34 @@ -# Puma can serve each request in a thread from an internal thread pool. -# The `threads` method setting takes two numbers: a minimum and maximum. -# Any libraries that use thread pools should be configured to match -# the maximum value specified for Puma. Default is set to 5 threads for minimum -# and maximum; this matches the default thread size of Active Record. -# -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 +# This configuration file will be evaluated by Puma. The top-level methods that +# are invoked here are part of Puma's configuration DSL. For more information +# about methods provided by the DSL, see https://puma.io/puma/Puma/DSL.html. -# Specifies the `port` that Puma will listen on to receive requests; default is 3000. +# Puma starts a configurable number of processes (workers) and each process +# serves each request in a thread from an internal thread pool. # -port ENV.fetch('PORT', 5000) - -# Specifies the `environment` that Puma will run in. +# The ideal number of threads per worker depends both on how much time the +# application spends waiting for IO operations and on how much you wish to +# to prioritize throughput over latency. # -environment ENV.fetch('RAILS_ENV') { 'development' } - -# Specifies the `pidfile` that Puma will use. -pidfile = ENV.fetch('PIDFILE') { 'tmp/pids/server.pid' } - -# Ensure that the pidfile path exists -Pathname(pidfile).dirname.mkpath - -# Specifies the number of `workers` to boot in clustered mode. -# Workers are forked web server processes. If using threads and workers together -# the concurrency of the application would be max `threads` * `workers`. -# Workers do not work on JRuby or Windows (both of which do not support -# processes). +# As a rule of thumb, increasing the number of threads will increase how much +# traffic a given process can handle (throughput), but due to CRuby's +# Global VM Lock (GVL) it has diminishing returns and will degrade the +# response time (latency) of the application. # -# workers ENV.fetch("WEB_CONCURRENCY") { 2 } - -# Use the `preload_app!` method when specifying a `workers` number. -# This directive tells Puma to first boot the application and load code -# before forking the application. This takes advantage of Copy On Write -# process behavior so workers use less memory. +# The default is set to 3 threads as it's deemed a decent compromise between +# throughput and latency for the average Rails application. # -# preload_app! +# Any libraries that use a connection pool or another resource pool should +# be configured to provide at least as many connections as the number of +# threads. This includes Active Record's `pool` parameter in `database.yml`. +threads_count = ENV.fetch("RAILS_MAX_THREADS", 5) +threads threads_count, threads_count -# Allow puma to be restarted by `rails restart` command. +# Specifies the `port` that Puma will listen on to receive requests; default is 3000. +port ENV.fetch("PORT", 3000) + +# Allow puma to be restarted by `bin/rails restart` command. plugin :tmp_restart + +# Specify the PID file. Defaults to tmp/pids/server.pid in development. +# In other environments, only set the PID file if requested. +pidfile ENV["PIDFILE"] if ENV["PIDFILE"] \ No newline at end of file diff --git a/db/migrate/20250913233759_add_service_name_to_active_storage_blobs.active_storage.rb b/db/migrate/20250913233759_add_service_name_to_active_storage_blobs.active_storage.rb new file mode 100644 index 000000000..a15c6ce8e --- /dev/null +++ b/db/migrate/20250913233759_add_service_name_to_active_storage_blobs.active_storage.rb @@ -0,0 +1,22 @@ +# This migration comes from active_storage (originally 20190112182829) +class AddServiceNameToActiveStorageBlobs < ActiveRecord::Migration[6.0] + def up + return unless table_exists?(:active_storage_blobs) + + unless column_exists?(:active_storage_blobs, :service_name) + add_column :active_storage_blobs, :service_name, :string + + if configured_service = ActiveStorage::Blob.service.name + ActiveStorage::Blob.unscoped.update_all(service_name: configured_service) + end + + change_column :active_storage_blobs, :service_name, :string, null: false + end + end + + def down + return unless table_exists?(:active_storage_blobs) + + remove_column :active_storage_blobs, :service_name + end +end diff --git a/db/migrate/20250913233760_create_active_storage_variant_records.active_storage.rb b/db/migrate/20250913233760_create_active_storage_variant_records.active_storage.rb new file mode 100644 index 000000000..94ac83af0 --- /dev/null +++ b/db/migrate/20250913233760_create_active_storage_variant_records.active_storage.rb @@ -0,0 +1,27 @@ +# This migration comes from active_storage (originally 20191206030411) +class CreateActiveStorageVariantRecords < ActiveRecord::Migration[6.0] + def change + return unless table_exists?(:active_storage_blobs) + + # Use Active Record's configured type for primary key + create_table :active_storage_variant_records, id: primary_key_type, if_not_exists: true do |t| + t.belongs_to :blob, null: false, index: false, type: blobs_primary_key_type + t.string :variation_digest, null: false + + t.index %i[ blob_id variation_digest ], name: "index_active_storage_variant_records_uniqueness", unique: true + t.foreign_key :active_storage_blobs, column: :blob_id + end + end + + private + def primary_key_type + config = Rails.configuration.generators + config.options[config.orm][:primary_key_type] || :primary_key + end + + def blobs_primary_key_type + pkey_name = connection.primary_key(:active_storage_blobs) + pkey_column = connection.columns(:active_storage_blobs).find { |c| c.name == pkey_name } + pkey_column.bigint? ? :bigint : pkey_column.type + end +end diff --git a/db/migrate/20250913233761_remove_not_null_on_active_storage_blobs_checksum.active_storage.rb b/db/migrate/20250913233761_remove_not_null_on_active_storage_blobs_checksum.active_storage.rb new file mode 100644 index 000000000..93c8b85ad --- /dev/null +++ b/db/migrate/20250913233761_remove_not_null_on_active_storage_blobs_checksum.active_storage.rb @@ -0,0 +1,8 @@ +# This migration comes from active_storage (originally 20211119233751) +class RemoveNotNullOnActiveStorageBlobsChecksum < ActiveRecord::Migration[6.0] + def change + return unless table_exists?(:active_storage_blobs) + + change_column_null(:active_storage_blobs, :checksum, true) + end +end diff --git a/db/schema.rb b/db/schema.rb index 26fcbda0c..12105bdff 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[7.0].define(version: 2024_02_02_124405) do +ActiveRecord::Schema[7.2].define(version: 2025_09_13_233761) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" diff --git a/public/404.html b/public/404.html new file mode 100644 index 000000000..2be3af26f --- /dev/null +++ b/public/404.html @@ -0,0 +1,67 @@ + + + + The page you were looking for doesn't exist (404) + + + + + + +
+
+

The page you were looking for doesn't exist.

+

You may have mistyped the address or the page may have moved.

+
+

If you are the application owner check the logs for more information.

+
+ + diff --git a/public/406-unsupported-browser.html b/public/406-unsupported-browser.html new file mode 100644 index 000000000..7cf1e168e --- /dev/null +++ b/public/406-unsupported-browser.html @@ -0,0 +1,66 @@ + + + + Your browser is not supported (406) + + + + + + +
+
+

Your browser is not supported.

+

Please upgrade your browser to continue.

+
+
+ + diff --git a/public/422.html b/public/422.html new file mode 100644 index 000000000..c08eac0d1 --- /dev/null +++ b/public/422.html @@ -0,0 +1,67 @@ + + + + The change you wanted was rejected (422) + + + + + + +
+
+

The change you wanted was rejected.

+

Maybe you tried to change something you didn't have access to.

+
+

If you are the application owner check the logs for more information.

+
+ + diff --git a/public/500.html b/public/500.html new file mode 100644 index 000000000..78a030af2 --- /dev/null +++ b/public/500.html @@ -0,0 +1,66 @@ + + + + We're sorry, but something went wrong (500) + + + + + + +
+
+

We're sorry, but something went wrong.

+
+

If you are the application owner check the logs for more information.

+
+ + diff --git a/public/icon.png b/public/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..f3b5abcbde91cf6d7a6a26e514eb7e30f476f950 GIT binary patch literal 5599 zcmeHL-D}fO6hCR_taXJlzs3}~RuB=Iujyo=i*=1|1FN%E=zNfMTjru|Q<6v{J{U!C zBEE}?j6I3sz>fzN!6}L_BKjcuASk~1;Dg|U_@d{g?V8mM`~#9U+>>*Ezw>c(PjYWA z4(;!cgge6k5E&d$G5`S-0}!Ik>CV(0Y#1}s-v_gAHhja2=W1?nBAte9D2HG<(+)uj z!5=W4u*{VKMw#{V@^NNs4TClr!FAA%ID-*gc{R%CFKEzG<6gm*9s_uy)oMGW*=nJf zw{(Mau|2FHfXIv6C0@Wk5k)F=3jo1srV-C{pl&k&)4_&JjYrnbJiul}d0^NCSh(#7h=F;3{|>EU>h z6U8_p;^wK6mAB(1b92>5-HxJ~V}@3?G`&Qq-TbJ2(&~-HsH6F#8mFaAG(45eT3VPO zM|(Jd<+;UZs;w>0Qw}0>D%{~r{uo_Fl5_Bo3ABWi zWo^j^_T3dxG6J6fH8X)$a^%TJ#PU!=LxF=#Fd9EvKx_x>q<(KY%+y-08?kN9dXjXK z**Q=yt-FTU*13ouhCdqq-0&;Ke{T3sQU9IdzhV9LhQIpq*P{N)+}|Mh+a-VV=x?R} c>%+pvTcMWshj-umO}|qP?%A)*_KlqT3uEqhU;qFB literal 0 HcmV?d00001 diff --git a/public/icon.svg b/public/icon.svg new file mode 100644 index 000000000..78307ccd4 --- /dev/null +++ b/public/icon.svg @@ -0,0 +1,3 @@ + + + From d1212d6eb08506629e2dcbfecd67cb3a346cd74b Mon Sep 17 00:00:00 2001 From: Lodewiges Date: Mon, 15 Sep 2025 20:27:27 +0200 Subject: [PATCH 2/8] lint fixes --- .rubocop.yml | 4 ++-- config/environments/development.rb | 10 ++++----- config/environments/production.rb | 6 +++--- config/environments/test.rb | 8 +++---- .../initializers/filter_parameter_logging.rb | 4 ++-- config/puma.rb | 6 +++--- ..._to_active_storage_blobs.active_storage.rb | 12 +++++------ ..._storage_variant_records.active_storage.rb | 21 ++++++++++--------- 8 files changed, 36 insertions(+), 35 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 8ef3de710..af48d0f4d 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -6,8 +6,8 @@ plugins: - rubocop-rspec_rails AllCops: - TargetRailsVersion: 7.1 - TargetRubyVersion: 3.3 + TargetRailsVersion: 7.2 + TargetRubyVersion: 3.4 Exclude: - 'bin/**/*' - 'db/schema.rb' diff --git a/config/environments/development.rb b/config/environments/development.rb index 154bf0af0..73905422a 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -1,4 +1,4 @@ -require "active_support/core_ext/integer/time" +require 'active_support/core_ext/integer/time' Rails.application.configure do # Settings specified here will take precedence over those in config/application.rb. @@ -23,12 +23,12 @@ # Enable/disable caching. By default caching is disabled. # Run rails dev:cache to toggle caching. - if Rails.root.join("tmp/caching-dev.txt").exist? + if Rails.root.join('tmp', 'caching-dev.txt', 'caching-dev.txt').exist? config.action_controller.perform_caching = true config.action_controller.enable_fragment_cache_logging = true config.cache_store = :memory_store - config.public_file_server.headers = { "Cache-Control" => "public, max-age=#{2.days.to_i}" } + config.public_file_server.headers = { 'Cache-Control' => "public, max-age=#{2.days.to_i}" } else config.action_controller.perform_caching = false @@ -46,7 +46,7 @@ config.action_mailer.perform_caching = false # Set the default host and port for links in emails to the main Rails app. - config.action_mailer.default_url_options = { host: "localhost", port: 5000 } + config.action_mailer.default_url_options = { host: 'localhost', port: 5000 } # Set the asset host for images/styles in emails to the Webpacker dev server. config.action_mailer.asset_host = 'http://localhost:5000' @@ -99,4 +99,4 @@ Bullet.enable = true Bullet.console = true # Log alerts to the browser console end -end \ No newline at end of file +end diff --git a/config/environments/production.rb b/config/environments/production.rb index 738b0cf68..2dbd68353 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -58,9 +58,9 @@ # config.ssl_options = { redirect: { exclude: ->(request) { request.path == "/up" } } } # Log to STDOUT by default -+ config.logger = ActiveSupport::Logger.new(STDOUT) -+ .tap { |logger| logger.formatter = ::Logger::Formatter.new } -+ .then { |logger| ActiveSupport::TaggedLogging.new(logger) } + config.logger = ActiveSupport::Logger.new(STDOUT) + .tap { |logger| logger.formatter = ::Logger::Formatter.new } + .then { |logger| ActiveSupport::TaggedLogging.new(logger) } # Prepend all log lines with the following tags. config.log_tags = [:request_id] diff --git a/config/environments/test.rb b/config/environments/test.rb index 02320f244..b544118d1 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -1,4 +1,4 @@ -require "active_support/core_ext/integer/time" +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 @@ -15,10 +15,10 @@ # 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? + config.eager_load = ENV['CI'].present? # Configure public file server for tests with Cache-Control for performance. - 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 @@ -45,7 +45,7 @@ # Unlike controllers, the mailer instance doesn't have any context about the # incoming request so you'll need to provide the :host parameter yourself. - config.action_mailer.default_url_options = { host: "www.example.com" } + config.action_mailer.default_url_options = { host: 'www.example.com' } # Print deprecation notices to the stderr. config.active_support.deprecation = :stderr diff --git a/config/initializers/filter_parameter_logging.rb b/config/initializers/filter_parameter_logging.rb index c010b83dd..58277c14b 100644 --- a/config/initializers/filter_parameter_logging.rb +++ b/config/initializers/filter_parameter_logging.rb @@ -3,6 +3,6 @@ # 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, :email, :secret, :token, :_key, :crypt, :salt, :certificate, :otp, :ssn +Rails.application.config.filter_parameters += %i[ + passw email secret token _key crypt salt certificate otp ssn ] diff --git a/config/puma.rb b/config/puma.rb index 8d6c2c360..849d94b5d 100644 --- a/config/puma.rb +++ b/config/puma.rb @@ -20,15 +20,15 @@ # Any libraries that use a connection pool or another resource pool should # be configured to provide at least as many connections as the number of # threads. This includes Active Record's `pool` parameter in `database.yml`. -threads_count = ENV.fetch("RAILS_MAX_THREADS", 5) +threads_count = ENV.fetch('RAILS_MAX_THREADS', 5) threads threads_count, threads_count # Specifies the `port` that Puma will listen on to receive requests; default is 3000. -port ENV.fetch("PORT", 3000) +port ENV.fetch('PORT', 3000) # Allow puma to be restarted by `bin/rails restart` command. plugin :tmp_restart # Specify the PID file. Defaults to tmp/pids/server.pid in development. # In other environments, only set the PID file if requested. -pidfile ENV["PIDFILE"] if ENV["PIDFILE"] \ No newline at end of file +pidfile ENV['PIDFILE'] if ENV['PIDFILE'] diff --git a/db/migrate/20250913233759_add_service_name_to_active_storage_blobs.active_storage.rb b/db/migrate/20250913233759_add_service_name_to_active_storage_blobs.active_storage.rb index a15c6ce8e..5b067923f 100644 --- a/db/migrate/20250913233759_add_service_name_to_active_storage_blobs.active_storage.rb +++ b/db/migrate/20250913233759_add_service_name_to_active_storage_blobs.active_storage.rb @@ -3,15 +3,15 @@ class AddServiceNameToActiveStorageBlobs < ActiveRecord::Migration[6.0] def up return unless table_exists?(:active_storage_blobs) - unless column_exists?(:active_storage_blobs, :service_name) - add_column :active_storage_blobs, :service_name, :string + return if column_exists?(:active_storage_blobs, :service_name) - if configured_service = ActiveStorage::Blob.service.name - ActiveStorage::Blob.unscoped.update_all(service_name: configured_service) - end + add_column :active_storage_blobs, :service_name, :string - change_column :active_storage_blobs, :service_name, :string, null: false + if (configured_service = ActiveStorage::Blob.service.name) + ActiveStorage::Blob.unscoped.update_all(service_name: configured_service) end + + change_column :active_storage_blobs, :service_name, :string, null: false end def down diff --git a/db/migrate/20250913233760_create_active_storage_variant_records.active_storage.rb b/db/migrate/20250913233760_create_active_storage_variant_records.active_storage.rb index 94ac83af0..58cc779a0 100644 --- a/db/migrate/20250913233760_create_active_storage_variant_records.active_storage.rb +++ b/db/migrate/20250913233760_create_active_storage_variant_records.active_storage.rb @@ -8,20 +8,21 @@ def change t.belongs_to :blob, null: false, index: false, type: blobs_primary_key_type t.string :variation_digest, null: false - t.index %i[ blob_id variation_digest ], name: "index_active_storage_variant_records_uniqueness", unique: true + t.index %i[blob_id variation_digest], name: 'index_active_storage_variant_records_uniqueness', unique: true t.foreign_key :active_storage_blobs, column: :blob_id end end private - def primary_key_type - config = Rails.configuration.generators - config.options[config.orm][:primary_key_type] || :primary_key - end - def blobs_primary_key_type - pkey_name = connection.primary_key(:active_storage_blobs) - pkey_column = connection.columns(:active_storage_blobs).find { |c| c.name == pkey_name } - pkey_column.bigint? ? :bigint : pkey_column.type - end + def primary_key_type + config = Rails.configuration.generators + config.options[config.orm][:primary_key_type] || :primary_key + end + + def blobs_primary_key_type + pkey_name = connection.primary_key(:active_storage_blobs) + pkey_column = connection.columns(:active_storage_blobs).find { |c| c.name == pkey_name } + pkey_column.bigint? ? :bigint : pkey_column.type + end end From 5aaec8cb6ea2c9503565b5e8df0b902093a7ec7c Mon Sep 17 00:00:00 2001 From: Lodewiges Date: Mon, 15 Sep 2025 20:54:12 +0200 Subject: [PATCH 3/8] tried improving test --- app/models/invoice.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/models/invoice.rb b/app/models/invoice.rb index 0bea12bf5..1c1f8d323 100644 --- a/app/models/invoice.rb +++ b/app/models/invoice.rb @@ -31,10 +31,11 @@ def row_amount private def set_human_id - this_year_invoices = Invoice.where("human_id LIKE '?%'", Time.zone.now.year) + year_prefix = Time.zone.now.year.to_s + this_year_invoices = Invoice.where("human_id LIKE ?", "#{year_prefix}%") invoice_number = this_year_invoices.count + 1 - self.human_id = "#{Time.zone.now.year}#{invoice_number.to_s.rjust(4, '0')}" + self.human_id = "#{year_prefix}#{invoice_number.to_s.rjust(4, '0')}" end def activity_is_locked From c6fee74369f15814197826aac378acb6e1b5069a Mon Sep 17 00:00:00 2001 From: Lodewiges Date: Mon, 15 Sep 2025 21:02:52 +0200 Subject: [PATCH 4/8] fixed more lint --- app/models/invoice.rb | 2 +- config/environments/production.rb | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/app/models/invoice.rb b/app/models/invoice.rb index 1c1f8d323..2637d08b2 100644 --- a/app/models/invoice.rb +++ b/app/models/invoice.rb @@ -32,7 +32,7 @@ def row_amount def set_human_id year_prefix = Time.zone.now.year.to_s - this_year_invoices = Invoice.where("human_id LIKE ?", "#{year_prefix}%") + this_year_invoices = Invoice.where('human_id LIKE ?', "#{year_prefix}%") invoice_number = this_year_invoices.count + 1 self.human_id = "#{year_prefix}#{invoice_number.to_s.rjust(4, '0')}" diff --git a/config/environments/production.rb b/config/environments/production.rb index 2dbd68353..1e28770b8 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -58,9 +58,9 @@ # config.ssl_options = { redirect: { exclude: ->(request) { request.path == "/up" } } } # Log to STDOUT by default - config.logger = ActiveSupport::Logger.new(STDOUT) - .tap { |logger| logger.formatter = ::Logger::Formatter.new } - .then { |logger| ActiveSupport::TaggedLogging.new(logger) } + config.logger = ActiveSupport::Logger.new($stdout) + .tap { |logger| logger.formatter = Logger::Formatter.new } + .then { |logger| ActiveSupport::TaggedLogging.new(logger) } # Prepend all log lines with the following tags. config.log_tags = [:request_id] @@ -68,7 +68,7 @@ # "info" includes generic and useful information about system operation, but avoids logging too much # information to avoid inadvertent exposure of personally identifiable information (PII). If you # want to log everything, set the level to "debug". - config.log_level = ENV.fetch("RAILS_LOG_LEVEL", "info") + config.log_level = ENV.fetch('RAILS_LOG_LEVEL', 'info') # Use a different cache store in production. # config.cache_store = :mem_cache_store @@ -109,7 +109,7 @@ config.active_record.dump_schema_after_migration = false # Only use :id for inspections in production. - config.active_record.attributes_for_inspect = [ :id ] + config.active_record.attributes_for_inspect = [:id] # Enable DNS rebinding protection and other `Host` header attacks. # config.hosts = [ From ac357375fe5e6eb6898126d4689412fafd95d232 Mon Sep 17 00:00:00 2001 From: Lodewiges Date: Mon, 15 Sep 2025 22:42:23 +0200 Subject: [PATCH 5/8] maybe fixed tests --- Gemfile | 2 +- Gemfile.lock | 21 +++++++++++---------- config/environments/test.rb | 2 ++ 3 files changed, 14 insertions(+), 11 deletions(-) diff --git a/Gemfile b/Gemfile index aa602b934..bfd13f5fa 100644 --- a/Gemfile +++ b/Gemfile @@ -33,7 +33,7 @@ gem 'sassc-rails', '~> 2.1.2' gem 'sentry-rails', '~> 5.25' gem 'sentry-ruby', '~> 5.25' gem 'sentry-sidekiq', '~> 5.25' -gem 'sidekiq', '~> 8.0.4' +gem 'sidekiq', '~> 7.3.9' gem 'sidekiq-scheduler', '~> 6.0.1' gem 'simple_form', '~> 5.3.1' gem 'turbolinks', '~> 5.2.1' diff --git a/Gemfile.lock b/Gemfile.lock index 1198d487b..3cabdd776 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -395,7 +395,8 @@ GEM rdoc (6.14.0) erb psych (>= 4.0.0) - redis (4.8.1) + redis (5.4.1) + redis-client (>= 0.22.0) redis-actionpack (5.5.0) actionpack (>= 5) redis-rack (>= 2.1.0, < 4) @@ -412,8 +413,8 @@ GEM redis-actionpack (>= 5.0, < 6) redis-activesupport (>= 5.0, < 6) redis-store (>= 1.2, < 2) - redis-store (1.9.1) - redis (>= 4, < 5) + redis-store (1.11.0) + redis (>= 4, < 6) regexp_parser (2.10.0) reline (0.6.1) io-console (~> 0.5) @@ -507,12 +508,12 @@ GEM sentry-ruby (~> 5.25.0) sidekiq (>= 3.0) shellany (0.0.1) - sidekiq (8.0.4) - connection_pool (>= 2.5.0) - json (>= 2.9.0) - logger (>= 1.6.2) - rack (>= 3.1.0) - redis-client (>= 0.23.2) + sidekiq (7.3.9) + base64 + connection_pool (>= 2.3.0) + logger + rack (>= 2.2.4) + redis-client (>= 0.22.2) sidekiq-scheduler (6.0.1) rufus-scheduler (~> 3.2) sidekiq (>= 7.3, < 9) @@ -657,7 +658,7 @@ DEPENDENCIES sentry-rails (~> 5.25) sentry-ruby (~> 5.25) sentry-sidekiq (~> 5.25) - sidekiq (~> 8.0.4) + sidekiq (~> 7.3.9) sidekiq-scheduler (~> 6.0.1) simple_form (~> 5.3.1) simplecov (~> 0.22.0) diff --git a/config/environments/test.rb b/config/environments/test.rb index b544118d1..a624e054c 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -6,6 +6,8 @@ # and recreated between test runs. Don't rely on the data there! Rails.application.configure do + + config.active_job.queue_adapter = :test # Settings specified here will take precedence over those in config/application.rb. # While tests run files are not watched, reloading is not necessary. From 9bbb2b96cddfdd981ef27d5f6249ca184de6024c Mon Sep 17 00:00:00 2001 From: Lodewiges Date: Mon, 15 Sep 2025 23:10:29 +0200 Subject: [PATCH 6/8] reintroduce sidekiq 8.0.9 and set test queue adap --- .rubocop.yml | 2 +- Gemfile | 2 +- Gemfile.lock | 18 +++++++++--------- spec/rails_helper.rb | 2 +- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index af48d0f4d..966e69916 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -7,7 +7,7 @@ plugins: AllCops: TargetRailsVersion: 7.2 - TargetRubyVersion: 3.4 + TargetRubyVersion: 3.3 Exclude: - 'bin/**/*' - 'db/schema.rb' diff --git a/Gemfile b/Gemfile index bfd13f5fa..aa602b934 100644 --- a/Gemfile +++ b/Gemfile @@ -33,7 +33,7 @@ gem 'sassc-rails', '~> 2.1.2' gem 'sentry-rails', '~> 5.25' gem 'sentry-ruby', '~> 5.25' gem 'sentry-sidekiq', '~> 5.25' -gem 'sidekiq', '~> 7.3.9' +gem 'sidekiq', '~> 8.0.4' gem 'sidekiq-scheduler', '~> 6.0.1' gem 'simple_form', '~> 5.3.1' gem 'turbolinks', '~> 5.2.1' diff --git a/Gemfile.lock b/Gemfile.lock index 3cabdd776..f95f33fe3 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -111,7 +111,7 @@ GEM coderay (1.1.3) colorize (1.1.0) concurrent-ruby (1.3.5) - connection_pool (2.5.3) + connection_pool (2.5.4) consistency_fail (0.3.7) crass (1.0.6) date (3.4.1) @@ -404,7 +404,7 @@ GEM redis-activesupport (5.3.0) activesupport (>= 3, < 8) redis-store (>= 1.3, < 2) - redis-client (0.24.0) + redis-client (0.25.3) connection_pool redis-rack (3.0.0) rack-session (>= 0.2.0) @@ -508,12 +508,12 @@ GEM sentry-ruby (~> 5.25.0) sidekiq (>= 3.0) shellany (0.0.1) - sidekiq (7.3.9) - base64 - connection_pool (>= 2.3.0) - logger - rack (>= 2.2.4) - redis-client (>= 0.22.2) + sidekiq (8.0.7) + connection_pool (>= 2.5.0) + json (>= 2.9.0) + logger (>= 1.6.2) + rack (>= 3.1.0) + redis-client (>= 0.23.2) sidekiq-scheduler (6.0.1) rufus-scheduler (~> 3.2) sidekiq (>= 7.3, < 9) @@ -658,7 +658,7 @@ DEPENDENCIES sentry-rails (~> 5.25) sentry-ruby (~> 5.25) sentry-sidekiq (~> 5.25) - sidekiq (~> 7.3.9) + sidekiq (~> 8.0.4) sidekiq-scheduler (~> 6.0.1) simple_form (~> 5.3.1) simplecov (~> 0.22.0) diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb index f89ed97e9..423b15f2f 100644 --- a/spec/rails_helper.rb +++ b/spec/rails_helper.rb @@ -33,7 +33,7 @@ config.include Devise::Test::ControllerHelpers, type: :controller # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures - config.fixture_path = Rails.root.join('spec', 'fixtures') + config.fixture_paths = Rails.root.join('spec', 'fixtures') # If you're not using ActiveRecord, or you'd prefer not to run each of your # examples within a transaction, remove the following line or assign false From 84950afd576e05f69ad3bed410407831b6ced107 Mon Sep 17 00:00:00 2001 From: Lodewiges Date: Mon, 15 Sep 2025 23:25:08 +0200 Subject: [PATCH 7/8] final commit --- config/application.rb | 2 +- config/environments/test.rb | 1 - .../new_framework_defaults_7_2.rb | 70 ------------------- ..._to_active_storage_blobs.active_storage.rb | 2 +- 4 files changed, 2 insertions(+), 73 deletions(-) delete mode 100644 config/initializers/new_framework_defaults_7_2.rb diff --git a/config/application.rb b/config/application.rb index 90967a2de..34e59a189 100644 --- a/config/application.rb +++ b/config/application.rb @@ -9,7 +9,7 @@ module Sofia class Application < Rails::Application # Initialize configuration defaults for originally generated Rails version. - config.load_defaults 7.1 + config.load_defaults 7.2 # 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. diff --git a/config/environments/test.rb b/config/environments/test.rb index a624e054c..c2ed52ab7 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -6,7 +6,6 @@ # and recreated between test runs. Don't rely on the data there! Rails.application.configure do - config.active_job.queue_adapter = :test # Settings specified here will take precedence over those in config/application.rb. diff --git a/config/initializers/new_framework_defaults_7_2.rb b/config/initializers/new_framework_defaults_7_2.rb deleted file mode 100644 index b549c4a25..000000000 --- a/config/initializers/new_framework_defaults_7_2.rb +++ /dev/null @@ -1,70 +0,0 @@ -# Be sure to restart your server when you modify this file. -# -# This file eases your Rails 7.2 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.2`. -# -# Read the Guide for Upgrading Ruby on Rails for more info on each option. -# https://guides.rubyonrails.org/upgrading_ruby_on_rails.html - -### -# Controls whether Active Job's `#perform_later` and similar methods automatically defer -# the job queuing to after the current Active Record transaction is committed. -# -# Example: -# Topic.transaction do -# topic = Topic.create(...) -# NewTopicNotificationJob.perform_later(topic) -# end -# -# In this example, if the configuration is set to `:never`, the job will -# be enqueued immediately, even though the `Topic` hasn't been committed yet. -# Because of this, if the job is picked up almost immediately, or if the -# transaction doesn't succeed for some reason, the job will fail to find this -# topic in the database. -# -# If `enqueue_after_transaction_commit` is set to `:default`, the queue adapter -# will define the behaviour. -# -# Note: Active Job backends can disable this feature. This is generally done by -# backends that use the same database as Active Record as a queue, hence they -# don't need this feature. -#++ -# Rails.application.config.active_job.enqueue_after_transaction_commit = :default - -### -# Adds image/webp to the list of content types Active Storage considers as an image -# Prevents automatic conversion to a fallback PNG, and assumes clients support WebP, as they support gif, jpeg, and png. -# This is possible due to broad browser support for WebP, but older browsers and email clients may still not support -# WebP. Requires imagemagick/libvips built with WebP support. -#++ -# Rails.application.config.active_storage.web_image_content_types = %w[image/png image/jpeg image/gif image/webp] - -### -# Enable validation of migration timestamps. When set, an ActiveRecord::InvalidMigrationTimestampError -# will be raised if the timestamp prefix for a migration is more than a day ahead of the timestamp -# associated with the current time. This is done to prevent forward-dating of migration files, which can -# impact migration generation and other migration commands. -# -# Applications with existing timestamped migrations that do not adhere to the -# expected format can disable validation by setting this config to `false`. -#++ -# Rails.application.config.active_record.validate_migration_timestamps = true - -### -# Controls whether the PostgresqlAdapter should decode dates automatically with manual queries. -# -# Example: -# ActiveRecord::ConnectionAdapters::PostgreSQLAdapter.select_value("select '2024-01-01'::date") #=> Date -# -# This query used to return a `String`. -#++ -# Rails.application.config.active_record.postgresql_adapter_decode_dates = true - -### -# Enables YJIT as of Ruby 3.3, to bring sizeable performance improvements. If you are -# deploying to a memory constrained environment you may want to set this to `false`. -#++ -# Rails.application.config.yjit = true diff --git a/db/migrate/20250913233759_add_service_name_to_active_storage_blobs.active_storage.rb b/db/migrate/20250913233759_add_service_name_to_active_storage_blobs.active_storage.rb index 5b067923f..b10e40e8a 100644 --- a/db/migrate/20250913233759_add_service_name_to_active_storage_blobs.active_storage.rb +++ b/db/migrate/20250913233759_add_service_name_to_active_storage_blobs.active_storage.rb @@ -8,7 +8,7 @@ def up add_column :active_storage_blobs, :service_name, :string if (configured_service = ActiveStorage::Blob.service.name) - ActiveStorage::Blob.unscoped.update_all(service_name: configured_service) + ActiveStorage::Blob.unscoped.update_all(service_name: configured_service) # rubocop:disable Rails/SkipsModelValidations end change_column :active_storage_blobs, :service_name, :string, null: false From 2d6daa94cbe19f48851f22444f19853155e9abbb Mon Sep 17 00:00:00 2001 From: Lodewiges Date: Tue, 16 Sep 2025 00:52:55 +0200 Subject: [PATCH 8/8] fiks inleggen be unclear --- app/views/users/show.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/users/show.html.erb b/app/views/users/show.html.erb index 98868d3a9..9b746384a 100644 --- a/app/views/users/show.html.erb +++ b/app/views/users/show.html.erb @@ -72,7 +72,7 @@ <% end %>