From 6d6d319dabb3b0b93ad76d5d84604141ae861637 Mon Sep 17 00:00:00 2001 From: Charlotte Van Petegem Date: Sat, 14 Oct 2023 11:14:00 +0200 Subject: [PATCH] Update gemfile and run rails app:update --- .rubocop.yml | 1 + Gemfile | 3 +- Gemfile.lock | 158 +++++++------ bin/setup | 2 +- config/application.rb | 5 + config/environments/development.rb | 17 +- config/environments/production.rb | 42 ++-- config/environments/test.rb | 22 +- .../initializers/filter_parameter_logging.rb | 8 +- config/initializers/inflections.rb | 8 +- .../new_framework_defaults_7_1.rb | 223 ++++++++++++++++++ gemset.nix | 166 +++++++++---- test/controllers/albums_controller_test.rb | 20 +- test/controllers/artists_controller_test.rb | 18 +- .../auth_tokens_controller_test.rb | 4 +- .../cover_filenames_controller_test.rb | 6 +- test/controllers/genres_controller_test.rb | 8 +- test/controllers/labels_controller_test.rb | 8 +- test/controllers/locations_controller_test.rb | 8 +- test/controllers/rescans_controller_test.rb | 2 + test/controllers/tracks_controller_test.rb | 6 +- test/factories/albums.rb | 2 +- test/factories/artists.rb | 2 +- test/factories/auth_tokens.rb | 4 +- test/factories/codec_conversions.rb | 2 +- test/factories/playlist_items.rb | 6 +- test/factories/tracks.rb | 2 +- test/models/rescan_runner_test.rb | 4 +- 28 files changed, 554 insertions(+), 203 deletions(-) create mode 100644 config/initializers/new_framework_defaults_7_1.rb diff --git a/.rubocop.yml b/.rubocop.yml index 133dee5f..d17626ca 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,4 +1,5 @@ require: + - rubocop-factory_bot - rubocop-minitest - rubocop-rails diff --git a/Gemfile b/Gemfile index cf9e8526..b59d1267 100644 --- a/Gemfile +++ b/Gemfile @@ -5,7 +5,7 @@ ruby '~> 3.2.2' # Bundle edge Rails instead: gem 'rails', github: 'rails/rails' # Remove workaround in tracks_controller on transient rack update -gem 'rails', '~> 7.0' +gem 'rails', '~> 7.1' # Use postgresql as the database for Active Record gem 'pg', '>= 1.2.3', '< 2.0' # Use Puma as the app server @@ -50,6 +50,7 @@ end group :development do gem 'annotate', '~> 3.2' # Remove workaround in lib/tasks/annotate.rb when https://github.com/ctran/annotate_models/issues/696 is fixed + gem 'rubocop-factory_bot', '~> 2.24' gem 'rubocop-minitest', '~> 0.32.2' gem 'rubocop-rails', '~> 2.21' end diff --git a/Gemfile.lock b/Gemfile.lock index f8fb816b..737f96d6 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,75 +1,83 @@ GEM remote: https://rubygems.org/ specs: - actioncable (7.0.8) - actionpack (= 7.0.8) - activesupport (= 7.0.8) + actioncable (7.1.1) + actionpack (= 7.1.1) + activesupport (= 7.1.1) nio4r (~> 2.0) websocket-driver (>= 0.6.1) - actionmailbox (7.0.8) - actionpack (= 7.0.8) - activejob (= 7.0.8) - activerecord (= 7.0.8) - activestorage (= 7.0.8) - activesupport (= 7.0.8) + zeitwerk (~> 2.6) + actionmailbox (7.1.1) + actionpack (= 7.1.1) + activejob (= 7.1.1) + activerecord (= 7.1.1) + activestorage (= 7.1.1) + activesupport (= 7.1.1) mail (>= 2.7.1) net-imap net-pop net-smtp - actionmailer (7.0.8) - actionpack (= 7.0.8) - actionview (= 7.0.8) - activejob (= 7.0.8) - activesupport (= 7.0.8) + actionmailer (7.1.1) + actionpack (= 7.1.1) + actionview (= 7.1.1) + activejob (= 7.1.1) + activesupport (= 7.1.1) mail (~> 2.5, >= 2.5.4) net-imap net-pop net-smtp - rails-dom-testing (~> 2.0) - actionpack (7.0.8) - actionview (= 7.0.8) - activesupport (= 7.0.8) - rack (~> 2.0, >= 2.2.4) + rails-dom-testing (~> 2.2) + actionpack (7.1.1) + actionview (= 7.1.1) + activesupport (= 7.1.1) + nokogiri (>= 1.8.5) + 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) - actionpack (= 7.0.8) - activerecord (= 7.0.8) - activestorage (= 7.0.8) - activesupport (= 7.0.8) + rails-dom-testing (~> 2.2) + rails-html-sanitizer (~> 1.6) + actiontext (7.1.1) + actionpack (= 7.1.1) + activerecord (= 7.1.1) + activestorage (= 7.1.1) + activesupport (= 7.1.1) globalid (>= 0.6.0) nokogiri (>= 1.8.5) - actionview (7.0.8) - activesupport (= 7.0.8) + actionview (7.1.1) + activesupport (= 7.1.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_model_serializers (0.10.14) actionpack (>= 4.1) activemodel (>= 4.1) case_transform (>= 0.2) jsonapi-renderer (>= 0.1.1.beta1, < 0.3) - activejob (7.0.8) - activesupport (= 7.0.8) + activejob (7.1.1) + activesupport (= 7.1.1) globalid (>= 0.3.6) - activemodel (7.0.8) - activesupport (= 7.0.8) - activerecord (7.0.8) - activemodel (= 7.0.8) - activesupport (= 7.0.8) - activestorage (7.0.8) - actionpack (= 7.0.8) - activejob (= 7.0.8) - activerecord (= 7.0.8) - activesupport (= 7.0.8) + activemodel (7.1.1) + activesupport (= 7.1.1) + activerecord (7.1.1) + activemodel (= 7.1.1) + activesupport (= 7.1.1) + timeout (>= 0.4.0) + activestorage (7.1.1) + actionpack (= 7.1.1) + activejob (= 7.1.1) + activerecord (= 7.1.1) + activesupport (= 7.1.1) marcel (~> 1.0) - mini_mime (>= 1.1.0) - activesupport (7.0.8) + activesupport (7.1.1) + base64 + bigdecimal concurrent-ruby (~> 1.0, >= 1.0.2) + connection_pool (>= 2.2.5) + drb i18n (>= 1.6, < 2) minitest (>= 5.1) + mutex_m tzinfo (~> 2.0) annotate (3.2.0) activerecord (>= 3.2, < 8.0) @@ -77,6 +85,7 @@ GEM ast (2.4.2) base64 (0.1.1) bcrypt (3.1.19) + bigdecimal (3.1.4) bootsnap (1.16.0) msgpack (~> 1.2) builder (3.2.4) @@ -85,12 +94,15 @@ GEM codecov (0.6.0) simplecov (>= 0.15, < 0.22) concurrent-ruby (1.2.2) + connection_pool (2.4.1) crass (1.0.6) date (3.3.3) debug (1.8.0) irb (>= 1.5.0) reline (>= 0.3.1) docile (1.4.0) + drb (2.1.1) + ruby2_keywords erubi (1.12.0) et-orbi (1.2.7) tzinfo @@ -138,7 +150,6 @@ GEM net-pop net-smtp marcel (1.0.2) - method_source (1.0.0) mini_magick (4.11.0) mini_mime (1.1.5) mini_portile2 (2.8.4) @@ -146,14 +157,15 @@ GEM mocha (2.1.0) ruby2_keywords (>= 0.0.5) msgpack (1.6.0) - net-imap (0.3.7) + mutex_m (0.1.2) + net-imap (0.4.1) date net-protocol net-pop (0.1.2) net-protocol net-protocol (0.2.1) timeout - net-smtp (0.3.3) + net-smtp (0.4.0) net-protocol nio4r (2.5.9) nokogiri (1.15.4) @@ -175,22 +187,27 @@ GEM rack (2.2.8) rack-cors (2.0.1) rack (>= 2.0.0) + rack-session (1.0.1) + rack (< 3) rack-test (2.1.0) rack (>= 1.3) - rails (7.0.8) - actioncable (= 7.0.8) - actionmailbox (= 7.0.8) - actionmailer (= 7.0.8) - actionpack (= 7.0.8) - actiontext (= 7.0.8) - actionview (= 7.0.8) - activejob (= 7.0.8) - activemodel (= 7.0.8) - activerecord (= 7.0.8) - activestorage (= 7.0.8) - activesupport (= 7.0.8) + rackup (1.0.0) + rack (< 3) + webrick + rails (7.1.1) + actioncable (= 7.1.1) + actionmailbox (= 7.1.1) + actionmailer (= 7.1.1) + actionpack (= 7.1.1) + actiontext (= 7.1.1) + actionview (= 7.1.1) + activejob (= 7.1.1) + activemodel (= 7.1.1) + activerecord (= 7.1.1) + activestorage (= 7.1.1) + activesupport (= 7.1.1) bundler (>= 1.15.0) - railties (= 7.0.8) + railties (= 7.1.1) rails-dom-testing (2.2.0) activesupport (>= 5.0.0) minitest @@ -198,13 +215,14 @@ GEM rails-html-sanitizer (1.6.0) loofah (~> 2.21) nokogiri (~> 1.14) - railties (7.0.8) - actionpack (= 7.0.8) - activesupport (= 7.0.8) - method_source + railties (7.1.1) + actionpack (= 7.1.1) + activesupport (= 7.1.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.0.6) rdoc (6.5.0) @@ -227,6 +245,8 @@ GEM unicode-display_width (>= 2.4.0, < 3.0) rubocop-ast (1.29.0) parser (>= 3.2.1.0) + rubocop-factory_bot (2.24.0) + rubocop (~> 1.33) rubocop-minitest (0.32.2) rubocop (>= 1.39, < 2.0) rubocop-rails (2.21.2) @@ -250,6 +270,7 @@ GEM concurrent-ruby (~> 1.0) unicode-display_width (2.4.2) wahwah (1.5.1) + webrick (1.8.1) websocket-driver (0.7.6) websocket-extensions (>= 0.1.0) websocket-extensions (0.1.5) @@ -276,7 +297,8 @@ DEPENDENCIES puma (~> 6.4) pundit (~> 2.3) rack-cors (~> 2.0) - rails (~> 7.0) + rails (~> 7.1) + rubocop-factory_bot (~> 2.24) rubocop-minitest (~> 0.32.2) rubocop-rails (~> 2.21) simplecov (~> 0.21) diff --git a/bin/setup b/bin/setup index ec47b79b..3cd5a9d7 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 9fb2ef4b..c01a089a 100644 --- a/config/application.rb +++ b/config/application.rb @@ -19,6 +19,11 @@ class Application < Rails::Application # Initialize configuration defaults for originally generated Rails version. config.load_defaults 7.0 + # 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 diff --git a/config/environments/development.rb b/config/environments/development.rb index 9f7c0ea9..7a9fe9ee 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -6,7 +6,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 @@ -20,9 +20,6 @@ # Enable/disable caching. By default caching is disabled. # Run rails dev:cache to toggle caching. if Rails.root.join('tmp/caching-dev.txt').exist? - config.action_controller.perform_caching = true - config.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}" @@ -39,15 +36,27 @@ # Raise exceptions for all deprecations. config.active_support.deprecation = :raise + # 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 = :all + # 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 + # Highlight code that enqueued background job in logs. + config.active_job.verbose_enqueue_logs = true + # Raises error for missing translations. config.i18n.raise_on_missing_translations = true + # Raise error when a before_action's only/except options reference missing actions + config.action_controller.raise_on_missing_callback_actions = true + config.token_hash_rounds = 10 config.ffmpeg_log_location = Rails.root.join('log/ffmpeg.log').to_s config.transcode_cache_path = Rails.root.join('storage/transcode_cache').to_s diff --git a/config/environments/production.rb b/config/environments/production.rb index 935a2143..b1f35801 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -4,7 +4,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 @@ -19,9 +19,8 @@ # or in config/master.key. This key is used to decrypt credentials (and other encrypted files). config.require_master_key = false - # Disable serving static files from the `/public` folder by default since - # Apache or NGINX already handles this. - config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present? + # Enable static file serving from the `/public` folder (turn off if using NGINX/Apache for it). + config.public_file_server.enabled = true # Enable serving of images, stylesheets, and JavaScripts from an asset server. # config.asset_host = 'http://assets.example.com' @@ -36,13 +35,19 @@ # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. # config.force_ssl = true - # Include generic and useful information about system operation, but avoid logging too much - # information to avoid inadvertent exposure of personally identifiable information (PII). - config.log_level = :info + # 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 include 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 @@ -54,25 +59,20 @@ # the I18n.default_locale when a translation cannot be found). config.i18n.fallbacks = true - # Don't log any deprecations + # Don't log any deprecations. config.active_support.report_deprecations = false - # Use default logging formatter so that PID and timestamp are not suppressed. - config.log_formatter = Logger::Formatter.new - - # Use a different logger for distributed setups. - # require "syslog/logger" - # config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name') - - if ENV['RAILS_LOG_TO_STDOUT'].present? - logger = ActiveSupport::Logger.new($stdout) - logger.formatter = config.log_formatter - config.logger = ActiveSupport::TaggedLogging.new(logger) - end - # Do not dump schema after migrations. config.active_record.dump_schema_after_migration = false + # 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" } } + config.transcode_cache_expiry = -> { 3.days.ago } config.token_hash_rounds = 10 diff --git a/config/environments/test.rb b/config/environments/test.rb index 097da771..23c5bef6 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -8,12 +8,13 @@ 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. - config.cache_classes = true + # While tests run files are not watched, reloading is not necessary. + config.enable_reloading = false - # 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. @@ -28,7 +29,7 @@ config.cache_store = :null_store # Raise exceptions instead of rendering exception templates. - config.action_dispatch.show_exceptions = false + config.action_dispatch.show_exceptions = :rescuable # Disable request forgery protection in test environment. config.action_controller.allow_forgery_protection = false @@ -36,6 +37,12 @@ # Store uploaded files on the local file system in a temporary directory. config.active_storage.service = :test + # 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 = :all + # Raise exception for all deprecations. config.active_support.deprecation = :raise @@ -45,6 +52,9 @@ # 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 + # For tests we want these settings to remain the same, regardless of the configuration in application.rb config.transcode_cache_expiry = -> { 1.day.ago } config.recalculate_content_length_if = ->(af) { af.length > 299 || af.track.created_at.after?(1.month.ago) } diff --git a/config/initializers/filter_parameter_logging.rb b/config/initializers/filter_parameter_logging.rb index c18d37b5..262e8620 100644 --- a/config/initializers/filter_parameter_logging.rb +++ b/config/initializers/filter_parameter_logging.rb @@ -1,4 +1,8 @@ # Be sure to restart your server when you modify this file. -# Configure sensitive parameters which will be filtered from the log file. -Rails.application.config.filter_parameters += %i[passw secret] +# Configure parameters to be partially matched (e.g. passw matches password) and filtered from the log file. +# Use this to limit dissemination of sensitive information. +# See the ActiveSupport::ParameterFilter documentation for supported notations and behaviors. +Rails.application.config.filter_parameters += %i[ + passw secret token _key crypt salt certificate otp ssn +] diff --git a/config/initializers/inflections.rb b/config/initializers/inflections.rb index ac033bf9..3860f659 100644 --- a/config/initializers/inflections.rb +++ b/config/initializers/inflections.rb @@ -4,13 +4,13 @@ # are locale specific, and you may define rules for as many different # locales as you wish. All of these examples are active by default: # ActiveSupport::Inflector.inflections(:en) do |inflect| -# inflect.plural /^(ox)$/i, '\1en' -# inflect.singular /^(ox)en/i, '\1' -# inflect.irregular 'person', 'people' +# inflect.plural /^(ox)$/i, "\\1en" +# inflect.singular /^(ox)en/i, "\\1" +# inflect.irregular "person", "people" # inflect.uncountable %w( fish sheep ) # end # These inflection rules are supported but not enabled by default: # ActiveSupport::Inflector.inflections(:en) do |inflect| -# inflect.acronym 'RESTful' +# inflect.acronym "RESTful" # end diff --git a/config/initializers/new_framework_defaults_7_1.rb b/config/initializers/new_framework_defaults_7_1.rb new file mode 100644 index 00000000..d41af162 --- /dev/null +++ b/config/initializers/new_framework_defaults_7_1.rb @@ -0,0 +1,223 @@ +# Be sure to restart your server when you modify this file. +# +# This file eases your Rails 7.1 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.1`. +# +# Read the Guide for Upgrading Ruby on Rails for more info on each option. +# https://guides.rubyonrails.org/upgrading_ruby_on_rails.html + +# No longer add autoloaded paths into `$LOAD_PATH`. This means that you won't be able +# to manually require files that are managed by the autoloader, which you shouldn't do anyway. +# This will reduce the size of the load path, making `require` faster if you don't use bootsnap, or reduce the size +# of the bootsnap cache if you use it. +# Rails.application.config.add_autoload_paths_to_load_path = false + +# Remove the default X-Download-Options headers since it is used only by Internet Explorer. +# If you need to support Internet Explorer, add back `"X-Download-Options" => "noopen"`. +# Rails.application.config.action_dispatch.default_headers = { +# "X-Frame-Options" => "SAMEORIGIN", +# "X-XSS-Protection" => "0", +# "X-Content-Type-Options" => "nosniff", +# "X-Permitted-Cross-Domain-Policies" => "none", +# "Referrer-Policy" => "strict-origin-when-cross-origin" +# } + +# Do not treat an `ActionController::Parameters` instance +# as equal to an equivalent `Hash` by default. +# Rails.application.config.action_controller.allow_deprecated_parameters_hash_equality = false + +# Active Record Encryption now uses SHA-256 as its hash digest algorithm. Important: If you have +# data encrypted with previous Rails versions, there are two scenarios to consider: +# +# 1. If you have +config.active_support.key_generator_hash_digest_class+ configured as SHA1 (the default +# before Rails 7.0), you need to configure SHA-1 for Active Record Encryption too: +# Rails.application.config.active_record.encryption.hash_digest_class = OpenSSL::Digest::SHA1 +# 2. If you have +config.active_support.key_generator_hash_digest_class+ configured as SHA256 (the new default +# in 7.0), then you need to configure SHA-256 for Active Record Encryption: +# Rails.application.config.active_record.encryption.hash_digest_class = OpenSSL::Digest::SHA256 +# +# If you don't currently have data encrypted with Active Record encryption, you can disable this setting to +# configure the default behavior starting 7.1+: +# Rails.application.config.active_record.encryption.support_sha1_for_non_deterministic_encryption = false + +# No longer run after_commit callbacks on the first of multiple Active Record +# instances to save changes to the same database row within a transaction. +# Instead, run these callbacks on the instance most likely to have internal +# state which matches what was committed to the database, typically the last +# instance to save. +# Rails.application.config.active_record.run_commit_callbacks_on_first_saved_instances_in_transaction = false + +# Configures SQLite with a strict strings mode, which disables double-quoted string literals. +# +# SQLite has some quirks around double-quoted string literals. +# It first tries to consider double-quoted strings as identifier names, but if they don't exist +# it then considers them as string literals. Because of this, typos can silently go unnoticed. +# For example, it is possible to create an index for a non existing column. +# See https://www.sqlite.org/quirks.html#double_quoted_string_literals_are_accepted for more details. +# Rails.application.config.active_record.sqlite3_adapter_strict_strings_by_default = true + +# Disable deprecated singular associations names +# Rails.application.config.active_record.allow_deprecated_singular_associations_name = false + +# Enable the Active Job `BigDecimal` argument serializer, which guarantees +# roundtripping. Without this serializer, some queue adapters may serialize +# `BigDecimal` arguments as simple (non-roundtrippable) strings. +# +# When deploying an application with multiple replicas, old (pre-Rails 7.1) +# replicas will not be able to deserialize `BigDecimal` arguments from this +# serializer. Therefore, this setting should only be enabled after all replicas +# have been successfully upgraded to Rails 7.1. +# Rails.application.config.active_job.use_big_decimal_serializer = true + +# Specify if an `ArgumentError` should be raised if `Rails.cache` `fetch` or +# `write` are given an invalid `expires_at` or `expires_in` time. +# Options are `true`, and `false`. If `false`, the exception will be reported +# as `handled` and logged instead. +# Rails.application.config.active_support.raise_on_invalid_cache_expiration_time = true + +# Specify whether Query Logs will format tags using the SQLCommenter format +# (https://open-telemetry.github.io/opentelemetry-sqlcommenter/), or using the legacy format. +# Options are `:legacy` and `:sqlcommenter`. +# Rails.application.config.active_record.query_log_tags_format = :sqlcommenter + +# Specify the default serializer used by `MessageEncryptor` and `MessageVerifier` +# instances. +# +# The legacy default is `:marshal`, which is a potential vector for +# deserialization attacks in cases where a message signing secret has been +# leaked. +# +# In Rails 7.1, the new default is `:json_allow_marshal` which serializes and +# deserializes with `ActiveSupport::JSON`, but can fall back to deserializing +# with `Marshal` so that legacy messages can still be read. +# +# In Rails 7.2, the default will become `:json` which serializes and +# deserializes with `ActiveSupport::JSON` only. +# +# Alternatively, you can choose `:message_pack` or `:message_pack_allow_marshal`, +# which serialize with `ActiveSupport::MessagePack`. `ActiveSupport::MessagePack` +# can roundtrip some Ruby types that are not supported by JSON, and may provide +# improved performance, but it requires the `msgpack` gem. +# +# For more information, see +# https://guides.rubyonrails.org/v7.1/configuring.html#config-active-support-message-serializer +# +# If you are performing a rolling deploy of a Rails 7.1 upgrade, wherein servers +# that have not yet been upgraded must be able to read messages from upgraded +# servers, first deploy without changing the serializer, then set the serializer +# in a subsequent deploy. +# Rails.application.config.active_support.message_serializer = :json_allow_marshal + +# Enable a performance optimization that serializes message data and metadata +# together. This changes the message format, so messages serialized this way +# cannot be read by older versions of Rails. However, messages that use the old +# format can still be read, regardless of whether this optimization is enabled. +# +# To perform a rolling deploy of a Rails 7.1 upgrade, wherein servers that have +# not yet been upgraded must be able to read messages from upgraded servers, +# leave this optimization off on the first deploy, then enable it on a +# subsequent deploy. +# Rails.application.config.active_support.use_message_serializer_for_metadata = true + +# Set the maximum size for Rails log files. +# +# `config.load_defaults 7.1` does not set this value for environments other than +# development and test. +# +# if Rails.env.local? +# Rails.application.config.log_file_size = 100 * 1024 * 1024 +# end + +# Enable raising on assignment to attr_readonly attributes. The previous +# behavior would allow assignment but silently not persist changes to the +# database. +# Rails.application.config.active_record.raise_on_assign_to_attr_readonly = true + +# Enable validating only parent-related columns for presence when the parent is mandatory. +# The previous behavior was to validate the presence of the parent record, which performed an extra query +# to get the parent every time the child record was updated, even when parent has not changed. +# Rails.application.config.active_record.belongs_to_required_validates_foreign_key = false + +# Enable precompilation of `config.filter_parameters`. Precompilation can +# improve filtering performance, depending on the quantity and types of filters. +# Rails.application.config.precompile_filter_parameters = true + +# Enable before_committed! callbacks on all enrolled records in a transaction. +# The previous behavior was to only run the callbacks on the first copy of a record +# if there were multiple copies of the same record enrolled in the transaction. +# Rails.application.config.active_record.before_committed_on_all_records = true + +# Disable automatic column serialization into YAML. +# To keep the historic behavior, you can set it to `YAML`, however it is +# recommended to explicitly define the serialization method for each column +# rather than to rely on a global default. +# Rails.application.config.active_record.default_column_serializer = nil + +# Enable a performance optimization that serializes Active Record models +# in a faster and more compact way. +# +# To perform a rolling deploy of a Rails 7.1 upgrade, wherein servers that have +# not yet been upgraded must be able to read caches from upgraded servers, +# leave this optimization off on the first deploy, then enable it on a +# subsequent deploy. +# Rails.application.config.active_record.marshalling_format_version = 7.1 + +# Run `after_commit` and `after_*_commit` callbacks in the order they are defined in a model. +# This matches the behaviour of all other callbacks. +# In previous versions of Rails, they ran in the inverse order. +# Rails.application.config.active_record.run_after_transaction_callbacks_in_order_defined = true + +# Whether a `transaction` block is committed or rolled back when exited via `return`, `break` or `throw`. +# +# Rails.application.config.active_record.commit_transaction_on_non_local_return = true + +# Controls when to generate a value for has_secure_token declarations. +# +# Rails.application.config.active_record.generate_secure_token_on = :initialize + +# ** Please read carefully, this must be configured in config/application.rb ** +# Change the format of the cache entry. +# Changing this default means that all new cache entries added to the cache +# will have a different format that is not supported by Rails 7.0 +# applications. +# Only change this value after your application is fully deployed to Rails 7.1 +# and you have no plans to rollback. +# When you're ready to change format, add this to `config/application.rb` (NOT +# this file): +# config.active_support.cache_format_version = 7.1 + +# Configure Action View to use HTML5 standards-compliant sanitizers when they are supported on your +# platform. +# +# `Rails::HTML::Sanitizer.best_supported_vendor` will cause Action View to use HTML5-compliant +# sanitizers if they are supported, else fall back to HTML4 sanitizers. +# +# In previous versions of Rails, Action View always used `Rails::HTML4::Sanitizer` as its vendor. +# +# Rails.application.config.action_view.sanitizer_vendor = Rails::HTML::Sanitizer.best_supported_vendor + +# Configure Action Text to use an HTML5 standards-compliant sanitizer when it is supported on your +# platform. +# +# `Rails::HTML::Sanitizer.best_supported_vendor` will cause Action Text to use HTML5-compliant +# sanitizers if they are supported, else fall back to HTML4 sanitizers. +# +# In previous versions of Rails, Action Text always used `Rails::HTML4::Sanitizer` as its vendor. +# +# Rails.application.config.action_text.sanitizer_vendor = Rails::HTML::Sanitizer.best_supported_vendor + +# Configure the log level used by the DebugExceptions middleware when logging +# uncaught exceptions during requests +# Rails.application.config.action_dispatch.debug_exception_log_level = :error + +# Configure the test helpers in Action View, Action Dispatch, and rails-dom-testing to use HTML5 +# parsers. +# +# Nokogiri::HTML5 isn't supported on JRuby, so JRuby applications must set this to :html4. +# +# In previous versions of Rails, these test helpers always used an HTML4 parser. +# +# Rails.application.config.dom_testing_default_html_version = :html5 diff --git a/gemset.nix b/gemset.nix index 4dbf57b4..523a5d93 100644 --- a/gemset.nix +++ b/gemset.nix @@ -1,14 +1,14 @@ { actioncable = { - dependencies = ["actionpack" "activesupport" "nio4r" "websocket-driver"]; + dependencies = ["actionpack" "activesupport" "nio4r" "websocket-driver" "zeitwerk"]; groups = ["default"]; platforms = []; source = { remotes = ["https://rubygems.org"]; - sha256 = "117vxic67jnw6q637kmsb3ryj0x485295pz9a9y4z8xn9bdlsl0z"; + sha256 = "0zd3zjpmrx06jiiyrxmsj94mfcxraxr0h3qlk61860slakmn4sg9"; type = "gem"; }; - version = "7.0.8"; + version = "7.1.1"; }; actionmailbox = { dependencies = ["actionpack" "activejob" "activerecord" "activestorage" "activesupport" "mail" "net-imap" "net-pop" "net-smtp"]; @@ -16,10 +16,10 @@ platforms = []; source = { remotes = ["https://rubygems.org"]; - sha256 = "1r8ldj2giaz8cn49qkdqn5zc29gbsr5ky4fg6r7ali0yh1xh684l"; + sha256 = "13n7178paqy2p2svsh21yfvzmpf4anwgmnxx6anyslr90zcyksg1"; type = "gem"; }; - version = "7.0.8"; + version = "7.1.1"; }; actionmailer = { dependencies = ["actionpack" "actionview" "activejob" "activesupport" "mail" "net-imap" "net-pop" "net-smtp" "rails-dom-testing"]; @@ -27,21 +27,21 @@ platforms = []; source = { remotes = ["https://rubygems.org"]; - sha256 = "0w6gvj7ybniq89834hqww9rj2xypz9l91f8niwaws2yq1qklymr2"; + sha256 = "1nr7njlr6pccglqp36imc8mhff73agcdky57a9alrkyrbzdnll42"; type = "gem"; }; - version = "7.0.8"; + version = "7.1.1"; }; actionpack = { - dependencies = ["actionview" "activesupport" "rack" "rack-test" "rails-dom-testing" "rails-html-sanitizer"]; + dependencies = ["actionview" "activesupport" "nokogiri" "rack" "rack-session" "rack-test" "rails-dom-testing" "rails-html-sanitizer"]; groups = ["default" "development" "test"]; platforms = []; source = { remotes = ["https://rubygems.org"]; - sha256 = "1l319p0gipfgq8bp8dvbv97qqb72rad9zcqn5snhgv20cmpqr69b"; + sha256 = "0b2r4h30fybd064xicfjr38j3hpyqx622fb4fjl3rk5ya36b9r1d"; type = "gem"; }; - version = "7.0.8"; + version = "7.1.1"; }; actiontext = { dependencies = ["actionpack" "activerecord" "activestorage" "activesupport" "globalid" "nokogiri"]; @@ -49,10 +49,10 @@ platforms = []; source = { remotes = ["https://rubygems.org"]; - sha256 = "0i47r3n2m8qm002gx7c0lx1pv15pr2zy57dm8j38x960rsb655pp"; + sha256 = "04wjw7iy43vh8dsavi2mka11nkv85nxs7bx8aw85w2mrc3y69jfz"; type = "gem"; }; - version = "7.0.8"; + version = "7.1.1"; }; actionview = { dependencies = ["activesupport" "builder" "erubi" "rails-dom-testing" "rails-html-sanitizer"]; @@ -60,10 +60,10 @@ platforms = []; source = { remotes = ["https://rubygems.org"]; - sha256 = "0xnpdwj1d8m6c2d90jp9cs50ggiz0jj02ls2h9lg68k4k8mnjbd2"; + sha256 = "02c51f3a2kan3s45m21sx08jjz9xm4l2kvk475ir06vgmgr3girn"; type = "gem"; }; - version = "7.0.8"; + version = "7.1.1"; }; active_model_serializers = { dependencies = ["actionpack" "activemodel" "case_transform" "jsonapi-renderer"]; @@ -82,10 +82,10 @@ platforms = []; source = { remotes = ["https://rubygems.org"]; - sha256 = "1cn1ic7ml75jm0c10s7cm5mvcgfnafj0kjvvjavpjcxgz6lxcqyb"; + sha256 = "1qhpzjlh8sm8gqi11yng1sxayfn13pw9j2pgjw57bcmifpav6rd5"; type = "gem"; }; - version = "7.0.8"; + version = "7.1.1"; }; activemodel = { dependencies = ["activesupport"]; @@ -93,43 +93,43 @@ platforms = []; source = { remotes = ["https://rubygems.org"]; - sha256 = "004w8zaz2g3y6lnrsvlcmljll0m3ndqpgwf0wfscgq6iysibiglm"; + sha256 = "16m6szgwhs7xnrkbib7di872k40r2iffx06g4gjiy4bb2g1d6bqz"; type = "gem"; }; - version = "7.0.8"; + version = "7.1.1"; }; activerecord = { - dependencies = ["activemodel" "activesupport"]; + dependencies = ["activemodel" "activesupport" "timeout"]; groups = ["default" "development"]; platforms = []; source = { remotes = ["https://rubygems.org"]; - sha256 = "04wavps80q3pvhvfbmi4gs102y1p6mxbg8xylzvib35b6m92adpj"; + sha256 = "09b3x4g4b3ihx9mvahz6ysm8dv41l8vkdfhxg0bdcqm4yg007pgq"; type = "gem"; }; - version = "7.0.8"; + version = "7.1.1"; }; activestorage = { - dependencies = ["actionpack" "activejob" "activerecord" "activesupport" "marcel" "mini_mime"]; + dependencies = ["actionpack" "activejob" "activerecord" "activesupport" "marcel"]; groups = ["default"]; platforms = []; source = { remotes = ["https://rubygems.org"]; - sha256 = "0d6vm6alsp0g6f3548b615zxbz8l2wrmaikwgsf8kv11wf6swb4c"; + sha256 = "1400b9fa4zv39qs6ma0lirf840zdn7qp3v86l9vhgwjzzvhmkhhc"; type = "gem"; }; - version = "7.0.8"; + version = "7.1.1"; }; activesupport = { - dependencies = ["concurrent-ruby" "i18n" "minitest" "tzinfo"]; + dependencies = ["base64" "bigdecimal" "concurrent-ruby" "connection_pool" "drb" "i18n" "minitest" "mutex_m" "tzinfo"]; groups = ["default" "development" "test"]; platforms = []; source = { remotes = ["https://rubygems.org"]; - sha256 = "188kbwkn1lbhz40ala8ykp20jzqphgc68g3d8flin8cqa2xid0s5"; + sha256 = "18jqxsjz9vs89v9jwz4f5vw9yj91cc2l2jwlzfgnxg8wmyjbqw47"; type = "gem"; }; - version = "7.0.8"; + version = "7.1.1"; }; annotate = { dependencies = ["activerecord" "rake"]; @@ -172,6 +172,16 @@ }; version = "3.1.19"; }; + bigdecimal = { + groups = ["default" "development" "test"]; + platforms = []; + source = { + remotes = ["https://rubygems.org"]; + sha256 = "07y615s8yldk3k13lmkhpk1k190lcqvmxmnjwgh4bzjan9xrc36y"; + type = "gem"; + }; + version = "3.1.4"; + }; bootsnap = { dependencies = ["msgpack"]; groups = ["default"]; @@ -225,6 +235,16 @@ }; version = "1.2.2"; }; + connection_pool = { + groups = ["default" "development" "test"]; + platforms = []; + source = { + remotes = ["https://rubygems.org"]; + sha256 = "1x32mcpm2cl5492kd6lbjbaf17qsssmpx9kdyr7z1wcif2cwyh0g"; + type = "gem"; + }; + version = "2.4.1"; + }; crass = { groups = ["default" "development" "test"]; platforms = []; @@ -266,6 +286,17 @@ }; version = "1.4.0"; }; + drb = { + dependencies = ["ruby2_keywords"]; + groups = ["default" "development" "test"]; + platforms = []; + source = { + remotes = ["https://rubygems.org"]; + sha256 = "0h9c2qiam82y3caapa2x157j1lkk9954hrjg3p22hxcsk8fli3vb"; + type = "gem"; + }; + version = "2.1.1"; + }; erubi = { groups = ["default" "development" "test"]; platforms = []; @@ -479,16 +510,6 @@ }; version = "1.0.2"; }; - method_source = { - groups = ["default" "development" "test"]; - platforms = []; - source = { - remotes = ["https://rubygems.org"]; - sha256 = "1pnyh44qycnf9mzi1j6fywd5fkskv3x7nmsqrrws0rjn5dd4ayfp"; - type = "gem"; - }; - version = "1.0.0"; - }; mini_magick = { groups = ["default"]; platforms = []; @@ -550,16 +571,26 @@ }; version = "1.6.0"; }; + mutex_m = { + groups = ["default" "development" "test"]; + platforms = []; + source = { + remotes = ["https://rubygems.org"]; + sha256 = "1pkxnp7p44kvs460bbbgjarr7xy1j8kjjmhwkg1kypj9wgmwb6qa"; + type = "gem"; + }; + version = "0.1.2"; + }; net-imap = { dependencies = ["date" "net-protocol"]; groups = ["default"]; platforms = []; source = { remotes = ["https://rubygems.org"]; - sha256 = "0lf7wqg7czhaj51qsnmn28j7jmcxhkh3m28rl1cjrqsgjxhwj7r3"; + sha256 = "0d0r31b79appz95dd63wmasly1qjz3hn58ffxw6ix4mqk49jcbq2"; type = "gem"; }; - version = "0.3.7"; + version = "0.4.1"; }; net-pop = { dependencies = ["net-protocol"]; @@ -589,10 +620,10 @@ platforms = []; source = { remotes = ["https://rubygems.org"]; - sha256 = "1c6md06hm5bf6rv53sk54dl2vg038pg8kglwv3rayx0vk2mdql9x"; + sha256 = "1rx3758w0bmbr21s2nsc6llflsrnp50fwdnly3ixra4v53gbhzid"; type = "gem"; }; - version = "0.3.3"; + version = "0.4.0"; }; nio4r = { groups = ["default"]; @@ -720,6 +751,17 @@ }; version = "2.0.1"; }; + rack-session = { + dependencies = ["rack"]; + groups = ["default" "development" "test"]; + platforms = []; + source = { + remotes = ["https://rubygems.org"]; + sha256 = "11w6yd60n8ng1ncs1ajlv42dg08yks09drlsgriydgpcjwz21d40"; + type = "gem"; + }; + version = "1.0.1"; + }; rack-test = { dependencies = ["rack"]; groups = ["default" "development" "test"]; @@ -731,16 +773,27 @@ }; version = "2.1.0"; }; + rackup = { + dependencies = ["rack" "webrick"]; + groups = ["default" "development" "test"]; + platforms = []; + source = { + remotes = ["https://rubygems.org"]; + sha256 = "1wbr03334ba9ilcq25wh9913xciwj0j117zs60vsqm0zgwdkwpp9"; + type = "gem"; + }; + version = "1.0.0"; + }; rails = { dependencies = ["actioncable" "actionmailbox" "actionmailer" "actionpack" "actiontext" "actionview" "activejob" "activemodel" "activerecord" "activestorage" "activesupport" "railties"]; groups = ["default"]; platforms = []; source = { remotes = ["https://rubygems.org"]; - sha256 = "0rsqin156dawz7gzpy1ijs02afqcr4704vqj56s6yxng3a9ayhwf"; + sha256 = "05yw7n1fpnw2fslbyrsl081fwnki4ih8pz4qnnhmrfniq6n3drv6"; type = "gem"; }; - version = "7.0.8"; + version = "7.1.1"; }; rails-dom-testing = { dependencies = ["activesupport" "minitest" "nokogiri"]; @@ -765,15 +818,15 @@ version = "1.6.0"; }; railties = { - dependencies = ["actionpack" "activesupport" "method_source" "rake" "thor" "zeitwerk"]; + dependencies = ["actionpack" "activesupport" "irb" "rackup" "rake" "thor" "zeitwerk"]; groups = ["default" "development" "test"]; platforms = []; source = { remotes = ["https://rubygems.org"]; - sha256 = "0sfc16zrcn4jgf5xczb08n6prhmqqgg9f0b4mn73zlzg6cwmqchj"; + sha256 = "19zsl9svr67126r1lm35y7y40i16gpnz1ppapj2h5879cnrliwrw"; type = "gem"; }; - version = "7.0.8"; + version = "7.1.1"; }; rainbow = { groups = ["default" "development"]; @@ -859,6 +912,17 @@ }; version = "1.29.0"; }; + rubocop-factory_bot = { + dependencies = ["rubocop"]; + groups = ["development"]; + platforms = []; + source = { + remotes = ["https://rubygems.org"]; + sha256 = "1y79flwjwlaslyhfpg84di9n756ir6bm52n964620xsj658d661h"; + type = "gem"; + }; + version = "2.24.0"; + }; rubocop-minitest = { dependencies = ["rubocop"]; groups = ["development"]; @@ -1004,6 +1068,16 @@ }; version = "1.5.1"; }; + webrick = { + groups = ["default" "development" "test"]; + platforms = []; + source = { + remotes = ["https://rubygems.org"]; + sha256 = "13qm7s0gr2pmfcl7dxrmq38asaza4w0i2n9my4yzs499j731wh8r"; + type = "gem"; + }; + version = "1.8.1"; + }; websocket-driver = { dependencies = ["websocket-extensions"]; groups = ["default"]; diff --git a/test/controllers/albums_controller_test.rb b/test/controllers/albums_controller_test.rb index 56e11625..3efbf542 100644 --- a/test/controllers/albums_controller_test.rb +++ b/test/controllers/albums_controller_test.rb @@ -2,7 +2,7 @@ class AlbumsControllerTest < ActionDispatch::IntegrationTest setup do - @album = create :album, :with_image + @album = create(:album, :with_image) sign_in_as create(:user) end @@ -22,7 +22,7 @@ class AlbumsControllerTest < ActionDispatch::IntegrationTest test 'should create album for moderator' do sign_in_as create(:moderator) - album = build :album + album = build(:album) image = { data: Base64.encode64(Rails.root.join('test/files/image.jpg').read), @@ -46,7 +46,7 @@ class AlbumsControllerTest < ActionDispatch::IntegrationTest test 'should not create album without title' do sign_in_as create(:moderator) - album = build :album + album = build(:album) assert_difference('Album.count', 0) do post albums_url, params: { album: { release: album.release } } @@ -57,7 +57,7 @@ class AlbumsControllerTest < ActionDispatch::IntegrationTest test 'should create dependent album_labels' do sign_in_as create(:moderator) - album = build :album + album = build(:album) album_labels = (1..5).map do |_| { @@ -82,7 +82,7 @@ class AlbumsControllerTest < ActionDispatch::IntegrationTest test 'should create dependent album_artists' do sign_in_as create(:moderator) - album = build :album + album = build(:album) album_artists = (1..5).map do |i| { @@ -147,7 +147,7 @@ class AlbumsControllerTest < ActionDispatch::IntegrationTest test 'should update album for moderator' do sign_in_as create(:moderator) - album = create :album + album = create(:album) image = { data: Base64.encode64(Rails.root.join('test/files/image.jpg').read), @@ -165,7 +165,7 @@ class AlbumsControllerTest < ActionDispatch::IntegrationTest test 'should destroy previous image when image is replaced' do sign_in_as create(:moderator) - album = create :album, :with_image + album = create(:album, :with_image) image = { data: Base64.encode64(Rails.root.join('test/files/image.jpg').read), @@ -185,7 +185,7 @@ class AlbumsControllerTest < ActionDispatch::IntegrationTest test 'should destroy previous image when image is cleared' do sign_in_as create(:moderator) - album = create :album, :with_image + album = create(:album, :with_image) image = { data: nil, @@ -234,8 +234,8 @@ class AlbumsControllerTest < ActionDispatch::IntegrationTest test 'should destroy empty albums for moderator' do sign_in_as create(:moderator) - album2 = create :album - create :track, album: album2 + album2 = create(:album) + create(:track, album: album2) assert_difference('Image.count', -1) do assert_difference('ActiveStorage::Blob.count', -1) do assert_difference('Album.count', -1) do diff --git a/test/controllers/artists_controller_test.rb b/test/controllers/artists_controller_test.rb index 9d5eb30e..a5beed05 100644 --- a/test/controllers/artists_controller_test.rb +++ b/test/controllers/artists_controller_test.rb @@ -2,7 +2,7 @@ class ArtistsControllerTest < ActionDispatch::IntegrationTest setup do - @artist = create :artist, :with_image + @artist = create(:artist, :with_image) sign_in_as create(:user) end @@ -22,7 +22,7 @@ class ArtistsControllerTest < ActionDispatch::IntegrationTest test 'should create artist for moderator' do sign_in_as create(:moderator) - artist = build :artist + artist = build(:artist) image = { data: Base64.encode64(Rails.root.join('test/files/image.jpg').read), @@ -94,7 +94,7 @@ class ArtistsControllerTest < ActionDispatch::IntegrationTest test 'should update artist for moderator' do sign_in_as create(:moderator) - artist = create :artist + artist = create(:artist) image = { data: Base64.encode64(Rails.root.join('test/files/image.jpg').read), @@ -112,7 +112,7 @@ class ArtistsControllerTest < ActionDispatch::IntegrationTest test 'should destroy previous image when image is replaced' do sign_in_as create(:moderator) - artist = create :artist, :with_image + artist = create(:artist, :with_image) image = { data: Base64.encode64(Rails.root.join('test/files/image.jpg').read), @@ -132,7 +132,7 @@ class ArtistsControllerTest < ActionDispatch::IntegrationTest test 'should destroy previous image when image is cleared' do sign_in_as create(:moderator) - artist = create :artist, :with_image + artist = create(:artist, :with_image) image = { data: nil, @@ -182,8 +182,8 @@ class ArtistsControllerTest < ActionDispatch::IntegrationTest test 'should destroy empty artists for moderator (track_artist)' do sign_in_as create(:moderator) - artist2 = create :artist - create :track_artist, artist: artist2 + artist2 = create(:artist) + create(:track_artist, artist: artist2) assert_difference('Image.count', -1) do assert_difference('ActiveStorage::Blob.count', -1) do @@ -202,8 +202,8 @@ class ArtistsControllerTest < ActionDispatch::IntegrationTest test 'should destroy empty artists for moderator (album_artist)' do sign_in_as create(:moderator) - artist2 = create :artist - create :album_artist, artist: artist2 + artist2 = create(:artist) + create(:album_artist, artist: artist2) assert_difference('Image.count', -1) do assert_difference('ActiveStorage::Blob.count', -1) do diff --git a/test/controllers/auth_tokens_controller_test.rb b/test/controllers/auth_tokens_controller_test.rb index 1fbf18f9..1e169dc9 100644 --- a/test/controllers/auth_tokens_controller_test.rb +++ b/test/controllers/auth_tokens_controller_test.rb @@ -49,7 +49,7 @@ class AuthTokensControllerTest < ActionDispatch::IntegrationTest test 'should show auth_token' do sign_in_as(@user) - auth_token = create :auth_token, user: @user + auth_token = create(:auth_token, user: @user) get auth_token_url(auth_token) assert_response :success @@ -57,7 +57,7 @@ class AuthTokensControllerTest < ActionDispatch::IntegrationTest test 'should destroy auth_token' do sign_in_as(@user) - auth_token = create :auth_token, user: @user + auth_token = create(:auth_token, user: @user) assert_difference('AuthToken.count', -1) do delete auth_token_url(auth_token) end diff --git a/test/controllers/cover_filenames_controller_test.rb b/test/controllers/cover_filenames_controller_test.rb index ba0df0ac..7dc1eac8 100644 --- a/test/controllers/cover_filenames_controller_test.rb +++ b/test/controllers/cover_filenames_controller_test.rb @@ -27,7 +27,7 @@ class CoverFilenamesControllerTest < ActionDispatch::IntegrationTest end test 'should not create cover_filename for user' do - cover_filename = build :cover_filename + cover_filename = build(:cover_filename) assert_difference('CoverFilename.count', 0) do post cover_filenames_url, params: { cover_filename: { filename: cover_filename.filename } } end @@ -46,7 +46,7 @@ class CoverFilenamesControllerTest < ActionDispatch::IntegrationTest test 'should create cover_filename for moderator' do sign_in_as create(:moderator) - cover_filename = build :cover_filename + cover_filename = build(:cover_filename) assert_difference('CoverFilename.count', 1) do post cover_filenames_url, params: { cover_filename: { filename: cover_filename.filename } } end @@ -56,7 +56,7 @@ class CoverFilenamesControllerTest < ActionDispatch::IntegrationTest test 'should create cover_filename for admin' do sign_in_as create(:admin) - cover_filename = build :cover_filename + cover_filename = build(:cover_filename) assert_difference('CoverFilename.count', 1) do post cover_filenames_url, params: { cover_filename: { filename: cover_filename.filename } } end diff --git a/test/controllers/genres_controller_test.rb b/test/controllers/genres_controller_test.rb index 59a15ccc..01d3a4f7 100644 --- a/test/controllers/genres_controller_test.rb +++ b/test/controllers/genres_controller_test.rb @@ -122,8 +122,8 @@ class GenresControllerTest < ActionDispatch::IntegrationTest test 'should destroy empty genres for moderator' do sign_in_as(create(:moderator)) - genre2 = create :genre - track = create :track + genre2 = create(:genre) + track = create(:track) track.update(genres: [genre2]) assert_difference('Genre.count', -1) do @@ -137,8 +137,8 @@ class GenresControllerTest < ActionDispatch::IntegrationTest test 'should destroy empty genres for admin' do sign_in_as(create(:admin)) - genre2 = create :genre - track = create :track + genre2 = create(:genre) + track = create(:track) track.update(genres: [genre2]) assert_difference('Genre.count', -1) do diff --git a/test/controllers/labels_controller_test.rb b/test/controllers/labels_controller_test.rb index 7c450e6a..cf10be2d 100644 --- a/test/controllers/labels_controller_test.rb +++ b/test/controllers/labels_controller_test.rb @@ -124,8 +124,8 @@ class LabelsControllerTest < ActionDispatch::IntegrationTest test 'should destroy empty labels for moderator' do sign_in_as(create(:moderator)) - label2 = create :label - create :album_label, label: label2 + label2 = create(:label) + create(:album_label, label: label2) assert_difference('Label.count', -1) do post destroy_empty_labels_url @@ -139,8 +139,8 @@ class LabelsControllerTest < ActionDispatch::IntegrationTest test 'should destroy empty labels for admin' do sign_in_as(create(:admin)) - label2 = create :label - create :album_label, label: label2 + label2 = create(:label) + create(:album_label, label: label2) assert_difference('Label.count', -1) do post destroy_empty_labels_url diff --git a/test/controllers/locations_controller_test.rb b/test/controllers/locations_controller_test.rb index 2be36599..9eafe705 100644 --- a/test/controllers/locations_controller_test.rb +++ b/test/controllers/locations_controller_test.rb @@ -2,7 +2,7 @@ class LocationsControllerTest < ActionDispatch::IntegrationTest setup do - @location = create :location + @location = create(:location) sign_in_as create(:user) end @@ -27,7 +27,7 @@ class LocationsControllerTest < ActionDispatch::IntegrationTest end test 'should not create location for user' do - location = build :location + location = build(:location) assert_difference('Location.count', 0) do post locations_url, params: { location: { path: location.path } } end @@ -46,7 +46,7 @@ class LocationsControllerTest < ActionDispatch::IntegrationTest test 'should create location for moderator' do sign_in_as create(:moderator) - location = build :location + location = build(:location) assert_difference('Location.count', 1) do post locations_url, params: { location: { path: location.path } } end @@ -56,7 +56,7 @@ class LocationsControllerTest < ActionDispatch::IntegrationTest test 'should create location for admin' do sign_in_as create(:admin) - location = build :location + location = build(:location) assert_difference('Location.count', 1) do post locations_url, params: { location: { path: location.path } } end diff --git a/test/controllers/rescans_controller_test.rb b/test/controllers/rescans_controller_test.rb index 8c65eba7..a60dc8ad 100644 --- a/test/controllers/rescans_controller_test.rb +++ b/test/controllers/rescans_controller_test.rb @@ -48,6 +48,7 @@ class RescansControllerTest < ActionDispatch::IntegrationTest assert_response :success @runner.reload + # TDOD(chvp): Flaky tests? assert_not_equal prev, @runner.finished_at end @@ -65,6 +66,7 @@ class RescansControllerTest < ActionDispatch::IntegrationTest assert_response :success @runner.reload + # TDOD(chvp): Flaky tests? assert_not_equal prev, @runner.finished_at end end diff --git a/test/controllers/tracks_controller_test.rb b/test/controllers/tracks_controller_test.rb index 916d8e0c..159c9b6a 100644 --- a/test/controllers/tracks_controller_test.rb +++ b/test/controllers/tracks_controller_test.rb @@ -190,7 +190,7 @@ class TracksControllerTest < ActionDispatch::IntegrationTest test 'should destroy empty tracks for moderator' do sign_in_as(create(:moderator)) - create :track + create(:track) assert_difference('Track.count', -1) do post destroy_empty_tracks_url @@ -309,7 +309,7 @@ class TracksControllerAudioTest < ActionDispatch::IntegrationTest test 'should not create transcoded_item if it already exists but should queue if file is gone' do io = StringIO.new Rails.root.join('test/files/base.flac').read AudioFile.any_instance.stubs(:convert).returns(io) - codec_conversion = create :codec_conversion + codec_conversion = create(:codec_conversion) location = Location.create(path: Rails.root.join('test/files')) flac = Codec.create(mimetype: 'audio/flac', extension: 'flac') audio_file = create(:audio_file, location:, filename: '/base.flac', codec: flac) @@ -330,7 +330,7 @@ class TracksControllerAudioTest < ActionDispatch::IntegrationTest test 'should not create transcoded_item if it already exists' do io = StringIO.new Rails.root.join('test/files/base.flac').read AudioFile.any_instance.stubs(:convert).returns(io) - codec_conversion = create :codec_conversion + codec_conversion = create(:codec_conversion) location = Location.create(path: Rails.root.join('test/files')) flac = Codec.create(mimetype: 'audio/flac', extension: 'flac') audio_file = create(:audio_file, location:, filename: '/base.flac', codec: flac) diff --git a/test/factories/albums.rb b/test/factories/albums.rb index 1855eaf5..5fddac59 100644 --- a/test/factories/albums.rb +++ b/test/factories/albums.rb @@ -21,7 +21,7 @@ release { Faker::Date.backward(days: 365 * 100) } trait :with_image do - association :image, factory: :image + image end transient do diff --git a/test/factories/artists.rb b/test/factories/artists.rb index af7ca632..2e68f8c6 100644 --- a/test/factories/artists.rb +++ b/test/factories/artists.rb @@ -17,7 +17,7 @@ review_comment { Faker::Lorem.word } trait :with_image do - association :image, factory: :image + image end end end diff --git a/test/factories/auth_tokens.rb b/test/factories/auth_tokens.rb index a3ceefc3..339756cc 100644 --- a/test/factories/auth_tokens.rb +++ b/test/factories/auth_tokens.rb @@ -15,11 +15,11 @@ user_agent { Faker::Internet.user_agent } factory :moderator_auth_token do - association :user, factory: :moderator + user factory: %i[moderator] end factory :admin_auth_token do - association :user, factory: :admin + user factory: %i[admin] end end end diff --git a/test/factories/codec_conversions.rb b/test/factories/codec_conversions.rb index 31e3536e..2053a582 100644 --- a/test/factories/codec_conversions.rb +++ b/test/factories/codec_conversions.rb @@ -10,7 +10,7 @@ FactoryBot.define do factory :codec_conversion do - association :resulting_codec, factory: :codec + resulting_codec factory: %i[codec] name { Faker::Lorem.unique.word } ffmpeg_params { Faker::Lorem.words(number: 10) } end diff --git a/test/factories/playlist_items.rb b/test/factories/playlist_items.rb index 7d62c31b..e3b9b00b 100644 --- a/test/factories/playlist_items.rb +++ b/test/factories/playlist_items.rb @@ -17,17 +17,17 @@ trait :for_album do playlist { association :playlist, playlist_type: :album } - association :item, factory: :album + item factory: %i[album] end trait :for_artist do playlist { association :playlist, playlist_type: :artist } - association :item, factory: :artist + item factory: %i[artist] end trait :for_track do playlist { association :playlist, playlist_type: :track } - association :item, factory: :track + item factory: %i[track] end end end diff --git a/test/factories/tracks.rb b/test/factories/tracks.rb index 1188dec3..6e0887c4 100644 --- a/test/factories/tracks.rb +++ b/test/factories/tracks.rb @@ -20,7 +20,7 @@ number { Random.rand(20) } review_comment { Faker::Lorem.word } trait :with_audio_file do - association :audio_file, factory: :audio_file + audio_file end end end diff --git a/test/models/rescan_runner_test.rb b/test/models/rescan_runner_test.rb index c5cc5c25..9b6db5ca 100644 --- a/test/models/rescan_runner_test.rb +++ b/test/models/rescan_runner_test.rb @@ -42,7 +42,7 @@ class RescanRunnerTest < ActiveSupport::TestCase end test 'schedule_all should create one task per runner' do - 3.times { create(:rescan_runner) } + create_list(:rescan_runner, 3) prev = RescanRunner.all.map(&:finished_at) RescanRunner.schedule_all @@ -627,7 +627,7 @@ class RescanRunnerTest < ActiveSupport::TestCase end test 'should not fail if genre is duplicated in tag and genre exists' do - create :genre, name: 'genre' + create(:genre, name: 'genre') @runner.location.update(path: Rails.root.join('test/files/success-duplicate-genre'))