1
0
Fork 0
mirror of https://github.com/mastodon/mastodon.git synced 2024-08-20 21:08:15 -07:00

Compare commits

...

14 commits

Author SHA1 Message Date
Matt Jankowski
e9ecfc7f42
Merge 0b274bd554 into 549ab089ee 2024-07-31 11:06:48 +00:00
Matt Jankowski
0b274bd554 Update test-prof to version 1.4.0.rc.4 2024-07-29 11:18:44 -04:00
Matt Jankowski
44c9e2cc04 Update test-prof to version 1.4.0.rc.3 2024-07-29 11:18:43 -04:00
Matt Jankowski
f1c47e5f34 Use test-prof 1.4.0.rc1 2024-07-29 11:18:43 -04:00
Matt Jankowski
229c800971 format 2024-07-29 11:18:43 -04:00
Matt Jankowski
a060a6b8bf cache store is memory store in test env 2024-07-29 11:18:43 -04:00
Matt Jankowski
aec78a7252 Restore default mail from 2024-07-29 11:18:43 -04:00
Matt Jankowski
85a761722c Use 7.2 defaults 2024-07-29 11:18:43 -04:00
Matt Jankowski
9ec81a663e Generated env updates 2024-07-29 11:18:43 -04:00
Matt Jankowski
cd6f72d40a Generated development.rb update 2024-07-29 11:18:43 -04:00
Matt Jankowski
d9edfaf111 New framework defaults 2024-07-29 11:18:43 -04:00
Matt Jankowski
30a793e463 Update safe reblog insert for Rails 7.2 2024-07-29 11:18:43 -04:00
Matt Jankowski
959c4e9224 Moved migration_context method to connection pool 2024-07-29 11:18:43 -04:00
Matt Jankowski
33b3457a9f Use rails version 7.2.0.beta3 2024-07-29 11:18:43 -04:00
11 changed files with 210 additions and 132 deletions

View file

@ -6,7 +6,7 @@ ruby '>= 3.1.0'
gem 'propshaft' gem 'propshaft'
gem 'puma', '~> 6.3' gem 'puma', '~> 6.3'
gem 'rack', '~> 2.2.7' gem 'rack', '~> 2.2.7'
gem 'rails', '~> 7.1.1' gem 'rails', '7.2.0.beta3'
gem 'thor', '~> 1.2' gem 'thor', '~> 1.2'
gem 'dotenv' gem 'dotenv'
@ -63,6 +63,7 @@ gem 'kaminari', '~> 1.2'
gem 'link_header', '~> 0.0' gem 'link_header', '~> 0.0'
gem 'mario-redis-lock', '~> 1.2', require: 'redis_lock' gem 'mario-redis-lock', '~> 1.2', require: 'redis_lock'
gem 'mime-types', '~> 3.5.0', require: 'mime/types/columnar' gem 'mime-types', '~> 3.5.0', require: 'mime/types/columnar'
gem 'mutex_m'
gem 'nokogiri', '~> 1.15' gem 'nokogiri', '~> 1.15'
gem 'nsa' gem 'nsa'
gem 'oj', '~> 3.14' gem 'oj', '~> 3.14'
@ -141,7 +142,7 @@ group :test do
gem 'selenium-webdriver' gem 'selenium-webdriver'
# Used to reset the database between system tests # Used to reset the database between system tests
gem 'database_cleaner-active_record' gem 'database_cleaner-active_record', github: 'DatabaseCleaner/database_cleaner-active_record' # TODO: Release version?
# Used to mock environment variables # Used to mock environment variables
gem 'climate_control' gem 'climate_control'
@ -208,7 +209,7 @@ group :development, :test do
gem 'memory_profiler', require: false gem 'memory_profiler', require: false
gem 'ruby-prof', require: false gem 'ruby-prof', require: false
gem 'stackprof', require: false gem 'stackprof', require: false
gem 'test-prof' gem 'test-prof', github: 'test-prof/test-prof'
# RSpec runner for rails # RSpec runner for rails
gem 'rspec-rails', '~> 6.0' gem 'rspec-rails', '~> 6.0'

View file

@ -7,38 +7,46 @@ GIT
hkdf (~> 0.2) hkdf (~> 0.2)
jwt (~> 2.0) jwt (~> 2.0)
GIT
remote: https://github.com/DatabaseCleaner/database_cleaner-active_record.git
revision: 79b08760d66369f43c40c49cc845a68ea9727e6e
specs:
database_cleaner-active_record (2.1.0)
activerecord (>= 5.a)
database_cleaner-core (~> 2.0.0)
GIT
remote: https://github.com/test-prof/test-prof.git
revision: 065ca2465118769a1a809dac66ff57f07562691d
specs:
test-prof (1.4.0.rc.4)
GEM GEM
remote: https://rubygems.org/ remote: https://rubygems.org/
specs: specs:
actioncable (7.1.3.4) actioncable (7.2.0.beta3)
actionpack (= 7.1.3.4) actionpack (= 7.2.0.beta3)
activesupport (= 7.1.3.4) activesupport (= 7.2.0.beta3)
nio4r (~> 2.0) nio4r (~> 2.0)
websocket-driver (>= 0.6.1) websocket-driver (>= 0.6.1)
zeitwerk (~> 2.6) zeitwerk (~> 2.6)
actionmailbox (7.1.3.4) actionmailbox (7.2.0.beta3)
actionpack (= 7.1.3.4) actionpack (= 7.2.0.beta3)
activejob (= 7.1.3.4) activejob (= 7.2.0.beta3)
activerecord (= 7.1.3.4) activerecord (= 7.2.0.beta3)
activestorage (= 7.1.3.4) activestorage (= 7.2.0.beta3)
activesupport (= 7.1.3.4) activesupport (= 7.2.0.beta3)
mail (>= 2.7.1) mail (>= 2.8.0)
net-imap actionmailer (7.2.0.beta3)
net-pop actionpack (= 7.2.0.beta3)
net-smtp actionview (= 7.2.0.beta3)
actionmailer (7.1.3.4) activejob (= 7.2.0.beta3)
actionpack (= 7.1.3.4) activesupport (= 7.2.0.beta3)
actionview (= 7.1.3.4) mail (>= 2.8.0)
activejob (= 7.1.3.4)
activesupport (= 7.1.3.4)
mail (~> 2.5, >= 2.5.4)
net-imap
net-pop
net-smtp
rails-dom-testing (~> 2.2) rails-dom-testing (~> 2.2)
actionpack (7.1.3.4) actionpack (7.2.0.beta3)
actionview (= 7.1.3.4) actionview (= 7.2.0.beta3)
activesupport (= 7.1.3.4) activesupport (= 7.2.0.beta3)
nokogiri (>= 1.8.5) nokogiri (>= 1.8.5)
racc racc
rack (>= 2.2.4) rack (>= 2.2.4)
@ -46,15 +54,16 @@ GEM
rack-test (>= 0.6.3) rack-test (>= 0.6.3)
rails-dom-testing (~> 2.2) rails-dom-testing (~> 2.2)
rails-html-sanitizer (~> 1.6) rails-html-sanitizer (~> 1.6)
actiontext (7.1.3.4) useragent (~> 0.16)
actionpack (= 7.1.3.4) actiontext (7.2.0.beta3)
activerecord (= 7.1.3.4) actionpack (= 7.2.0.beta3)
activestorage (= 7.1.3.4) activerecord (= 7.2.0.beta3)
activesupport (= 7.1.3.4) activestorage (= 7.2.0.beta3)
activesupport (= 7.2.0.beta3)
globalid (>= 0.6.0) globalid (>= 0.6.0)
nokogiri (>= 1.8.5) nokogiri (>= 1.8.5)
actionview (7.1.3.4) actionview (7.2.0.beta3)
activesupport (= 7.1.3.4) activesupport (= 7.2.0.beta3)
builder (~> 3.1) builder (~> 3.1)
erubi (~> 1.11) erubi (~> 1.11)
rails-dom-testing (~> 2.2) rails-dom-testing (~> 2.2)
@ -64,31 +73,31 @@ GEM
activemodel (>= 4.1) activemodel (>= 4.1)
case_transform (>= 0.2) case_transform (>= 0.2)
jsonapi-renderer (>= 0.1.1.beta1, < 0.3) jsonapi-renderer (>= 0.1.1.beta1, < 0.3)
activejob (7.1.3.4) activejob (7.2.0.beta3)
activesupport (= 7.1.3.4) activesupport (= 7.2.0.beta3)
globalid (>= 0.3.6) globalid (>= 0.3.6)
activemodel (7.1.3.4) activemodel (7.2.0.beta3)
activesupport (= 7.1.3.4) activesupport (= 7.2.0.beta3)
activerecord (7.1.3.4) activerecord (7.2.0.beta3)
activemodel (= 7.1.3.4) activemodel (= 7.2.0.beta3)
activesupport (= 7.1.3.4) activesupport (= 7.2.0.beta3)
timeout (>= 0.4.0) timeout (>= 0.4.0)
activestorage (7.1.3.4) activestorage (7.2.0.beta3)
actionpack (= 7.1.3.4) actionpack (= 7.2.0.beta3)
activejob (= 7.1.3.4) activejob (= 7.2.0.beta3)
activerecord (= 7.1.3.4) activerecord (= 7.2.0.beta3)
activesupport (= 7.1.3.4) activesupport (= 7.2.0.beta3)
marcel (~> 1.0) marcel (~> 1.0)
activesupport (7.1.3.4) activesupport (7.2.0.beta3)
base64 base64
bigdecimal bigdecimal
concurrent-ruby (~> 1.0, >= 1.0.2) concurrent-ruby (~> 1.0, >= 1.3.1)
connection_pool (>= 2.2.5) connection_pool (>= 2.2.5)
drb drb
i18n (>= 1.6, < 2) i18n (>= 1.6, < 2)
logger (>= 1.4.2)
minitest (>= 5.1) minitest (>= 5.1)
mutex_m tzinfo (~> 2.0, >= 2.0.5)
tzinfo (~> 2.0)
addressable (2.8.7) addressable (2.8.7)
public_suffix (>= 2.0.2, < 7.0) public_suffix (>= 2.0.2, < 7.0)
aes_key_wrap (1.1.0) aes_key_wrap (1.1.0)
@ -180,9 +189,6 @@ GEM
css_parser (1.17.1) css_parser (1.17.1)
addressable addressable
csv (3.3.0) csv (3.3.0)
database_cleaner-active_record (2.2.0)
activerecord (>= 5.a)
database_cleaner-core (~> 2.0.0)
database_cleaner-core (2.0.1) database_cleaner-core (2.0.1)
date (3.3.4) date (3.3.4)
debug (1.9.2) debug (1.9.2)
@ -638,20 +644,20 @@ GEM
rackup (1.0.0) rackup (1.0.0)
rack (< 3) rack (< 3)
webrick webrick
rails (7.1.3.4) rails (7.2.0.beta3)
actioncable (= 7.1.3.4) actioncable (= 7.2.0.beta3)
actionmailbox (= 7.1.3.4) actionmailbox (= 7.2.0.beta3)
actionmailer (= 7.1.3.4) actionmailer (= 7.2.0.beta3)
actionpack (= 7.1.3.4) actionpack (= 7.2.0.beta3)
actiontext (= 7.1.3.4) actiontext (= 7.2.0.beta3)
actionview (= 7.1.3.4) actionview (= 7.2.0.beta3)
activejob (= 7.1.3.4) activejob (= 7.2.0.beta3)
activemodel (= 7.1.3.4) activemodel (= 7.2.0.beta3)
activerecord (= 7.1.3.4) activerecord (= 7.2.0.beta3)
activestorage (= 7.1.3.4) activestorage (= 7.2.0.beta3)
activesupport (= 7.1.3.4) activesupport (= 7.2.0.beta3)
bundler (>= 1.15.0) bundler (>= 1.15.0)
railties (= 7.1.3.4) railties (= 7.2.0.beta3)
rails-controller-testing (1.0.5) rails-controller-testing (1.0.5)
actionpack (>= 5.0.1.rc1) actionpack (>= 5.0.1.rc1)
actionview (>= 5.0.1.rc1) actionview (>= 5.0.1.rc1)
@ -666,10 +672,10 @@ GEM
rails-i18n (7.0.9) rails-i18n (7.0.9)
i18n (>= 0.7, < 2) i18n (>= 0.7, < 2)
railties (>= 6.0.0, < 8) railties (>= 6.0.0, < 8)
railties (7.1.3.4) railties (7.2.0.beta3)
actionpack (= 7.1.3.4) actionpack (= 7.2.0.beta3)
activesupport (= 7.1.3.4) activesupport (= 7.2.0.beta3)
irb irb (~> 1.13)
rackup (>= 1.0.0) rackup (>= 1.0.0)
rake (>= 12.2) rake (>= 12.2)
thor (~> 1.0, >= 1.2.2) thor (~> 1.0, >= 1.2.2)
@ -836,7 +842,6 @@ GEM
unicode-display_width (>= 1.1.1, < 3) unicode-display_width (>= 1.1.1, < 3)
terrapin (1.0.1) terrapin (1.0.1)
climate_control climate_control
test-prof (1.3.3.1)
thor (1.3.1) thor (1.3.1)
tilt (2.3.0) tilt (2.3.0)
timeout (0.4.1) timeout (0.4.1)
@ -866,6 +871,7 @@ GEM
unf_ext (0.0.9.1) unf_ext (0.0.9.1)
unicode-display_width (2.5.0) unicode-display_width (2.5.0)
uri (0.13.0) uri (0.13.0)
useragent (0.16.10)
validate_email (0.1.6) validate_email (0.1.6)
activemodel (>= 3.0) activemodel (>= 3.0)
mail (>= 2.2.5) mail (>= 2.2.5)
@ -930,7 +936,7 @@ DEPENDENCIES
concurrent-ruby concurrent-ruby
connection_pool connection_pool
csv (~> 3.2) csv (~> 3.2)
database_cleaner-active_record database_cleaner-active_record!
debug (~> 1.8) debug (~> 1.8)
devise (~> 4.9) devise (~> 4.9)
devise-two-factor devise-two-factor
@ -975,6 +981,7 @@ DEPENDENCIES
md-paperclip-azure (~> 2.2) md-paperclip-azure (~> 2.2)
memory_profiler memory_profiler
mime-types (~> 3.5.0) mime-types (~> 3.5.0)
mutex_m
net-http (~> 0.4.0) net-http (~> 0.4.0)
net-ldap (~> 0.18) net-ldap (~> 0.18)
nokogiri (~> 1.15) nokogiri (~> 1.15)
@ -1014,7 +1021,7 @@ DEPENDENCIES
rack-attack (~> 6.6) rack-attack (~> 6.6)
rack-cors (~> 2.0) rack-cors (~> 2.0)
rack-test (~> 2.1) rack-test (~> 2.1)
rails (~> 7.1.1) rails (= 7.2.0.beta3)
rails-controller-testing (~> 1.0) rails-controller-testing (~> 1.0)
rails-i18n (~> 7.0) rails-i18n (~> 7.0)
rdf-normalize (~> 0.5) rdf-normalize (~> 0.5)
@ -1049,7 +1056,7 @@ DEPENDENCIES
stackprof stackprof
stoplight (~> 4.1) stoplight (~> 4.1)
strong_migrations strong_migrations
test-prof test-prof!
thor (~> 1.2) thor (~> 1.2)
tty-prompt (~> 0.23) tty-prompt (~> 0.23)
twitter-text (~> 3.1.0) twitter-text (~> 3.1.0)

View file

@ -6,7 +6,7 @@ class Admin::SystemCheck::DatabaseSchemaCheck < Admin::SystemCheck::BaseCheck
end end
def pass? def pass?
!ActiveRecord::Base.connection.migration_context.needs_migration? !ActiveRecord::Base.connection_pool.migration_context.needs_migration?
end end
def message def message

View file

@ -15,7 +15,9 @@ module Status::SafeReblogInsert
# #
# The code is kept similar to ActiveRecord::Persistence code and calls it # The code is kept similar to ActiveRecord::Persistence code and calls it
# directly when we are not handling a reblog. # directly when we are not handling a reblog.
def _insert_record(values, returning) #
# https://github.com/rails/rails/blob/7-2-stable/activerecord/lib/active_record/persistence.rb#L238-L263
def _insert_record(connection, values, returning)
return super unless values.is_a?(Hash) && values['reblog_of_id']&.value.present? return super unless values.is_a?(Hash) && values['reblog_of_id']&.value.present?
primary_key = self.primary_key primary_key = self.primary_key
@ -34,12 +36,17 @@ module Status::SafeReblogInsert
# Instead, we use a custom builder when a reblog is happening: # Instead, we use a custom builder when a reblog is happening:
im = _compile_reblog_insert(values) im = _compile_reblog_insert(values)
connection.insert(im, "#{self} Create", primary_key || false, primary_key_value, returning: returning).tap do |result| with_connection do |_c|
connection.insert(
im, "#{self} Create", primary_key || false, primary_key_value,
returning: returning
).tap do |result|
# Since we are using SELECT instead of VALUES, a non-error `nil` return is possible. # Since we are using SELECT instead of VALUES, a non-error `nil` return is possible.
# For our purposes, it's equivalent to a foreign key constraint violation # For our purposes, it's equivalent to a foreign key constraint violation
raise ActiveRecord::InvalidForeignKey, "(reblog_of_id)=(#{values['reblog_of_id'].value}) is not present in table \"statuses\"" if result.nil? raise ActiveRecord::InvalidForeignKey, "(reblog_of_id)=(#{values['reblog_of_id'].value}) is not present in table \"statuses\"" if result.nil?
end end
end end
end
def _compile_reblog_insert(values) def _compile_reblog_insert(values)
# This is somewhat equivalent to the following code of ActiveRecord::Persistence: # This is somewhat equivalent to the following code of ActiveRecord::Persistence:

View file

@ -61,10 +61,7 @@ Bundler.require(:pam_authentication) if ENV['PAM_ENABLED'] == 'true'
module Mastodon module Mastodon
class Application < Rails::Application class Application < Rails::Application
# Initialize configuration defaults for originally generated Rails version. # Initialize configuration defaults for originally generated Rails version.
config.load_defaults 7.1 config.load_defaults 7.2
# Explicitly set the cache format version to align with Rails version
config.active_support.cache_format_version = 7.1
# Please, add to the `ignore` list any other `lib` subdirectories that do # 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. # not contain `.rb` files, or that should not be reloaded or eager loaded.

View file

@ -16,7 +16,7 @@ Rails.application.configure do
# Show full error reports. # Show full error reports.
config.consider_all_requests_local = true config.consider_all_requests_local = true
# Enable server timing # Enable server timing.
config.server_timing = true config.server_timing = true
# Enable/disable caching. By default caching is disabled. # Enable/disable caching. By default caching is disabled.
@ -37,11 +37,6 @@ Rails.application.configure do
config.action_controller.forgery_protection_origin_check = ENV['DISABLE_FORGERY_REQUEST_PROTECTION'].nil? config.action_controller.forgery_protection_origin_check = ENV['DISABLE_FORGERY_REQUEST_PROTECTION'].nil?
ActiveSupport::Logger.new($stdout).tap do |logger|
logger.formatter = config.log_formatter
config.logger = ActiveSupport::TaggedLogging.new(logger)
end
# Generate random VAPID keys # Generate random VAPID keys
Webpush.generate_key.tap do |vapid_key| Webpush.generate_key.tap do |vapid_key|
config.x.vapid_private_key = vapid_key.private_key config.x.vapid_private_key = vapid_key.private_key
@ -53,6 +48,8 @@ Rails.application.configure do
config.action_mailer.perform_caching = false config.action_mailer.perform_caching = false
config.action_mailer.default_options = { from: 'notifications@localhost' }
# Print deprecation notices to the Rails logger. # Print deprecation notices to the Rails logger.
config.active_support.deprecation = :log config.active_support.deprecation = :log
@ -75,12 +72,7 @@ Rails.application.configure do
# config.i18n.raise_on_missing_translations = true # config.i18n.raise_on_missing_translations = true
# Annotate rendered view with file names. # Annotate rendered view with file names.
# config.action_view.annotate_rendered_view_with_filenames = true config.action_view.annotate_rendered_view_with_filenames = true
# Uncomment if you wish to allow Action Cable access from any origin.
# config.action_cable.disable_request_forgery_protection = true
config.action_mailer.default_options = { from: 'notifications@localhost' }
# If using a Heroku, Vagrant or generic remote development environment, # If using a Heroku, Vagrant or generic remote development environment,
# use letter_opener_web, accessible at /letter_opener. # use letter_opener_web, accessible at /letter_opener.
@ -90,8 +82,11 @@ Rails.application.configure do
# TODO: Remove once devise-two-factor data migration complete # TODO: Remove once devise-two-factor data migration complete
config.x.otp_secret = ENV.fetch('OTP_SECRET', '1fc2b87989afa6351912abeebe31ffc5c476ead9bf8b3d74cbc4a302c7b69a45b40b1bbef3506ddad73e942e15ed5ca4b402bf9a66423626051104f4b5f05109') config.x.otp_secret = ENV.fetch('OTP_SECRET', '1fc2b87989afa6351912abeebe31ffc5c476ead9bf8b3d74cbc4a302c7b69a45b40b1bbef3506ddad73e942e15ed5ca4b402bf9a66423626051104f4b5f05109')
# Raise error when a before_action's only/except options reference missing actions # Raise error when a before_action's only/except options reference missing actions.
config.action_controller.raise_on_missing_callback_actions = true config.action_controller.raise_on_missing_callback_actions = true
# Apply autocorrection by RuboCop to files generated by `bin/rails generate`.
# config.generators.apply_rubocop_autocorrect_after_generate!
end end
Redis.raise_deprecations = true Redis.raise_deprecations = true

View file

@ -17,20 +17,16 @@ Rails.application.configure do
# Full error reports are disabled and caching is turned on. # 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 config.action_controller.perform_caching = true
config.action_controller.asset_host = ENV['CDN_HOST'] if ENV['CDN_HOST'].present?
# Ensures that a master key has been made available in ENV["RAILS_MASTER_KEY"], config/master.key, or an environment # 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). # key such as config/credentials/production.key. This key is used to decrypt credentials (and other encrypted files).
# config.require_master_key = true # config.require_master_key = true
# Compress CSS using a preprocessor. # Disable serving static files from `public/`, relying on NGINX/Apache to do so instead.
# config.assets.css_compressor = :sass # config.public_file_server.enabled = false
# Do not fallback to assets pipeline if a precompiled asset is missed.
config.assets.compile = false
# Enable serving of images, stylesheets, and JavaScripts from an asset server. # Enable serving of images, stylesheets, and JavaScripts from an asset server.
# config.asset_host = "http://assets.example.com" config.asset_host = ENV['CDN_HOST'] if ENV['CDN_HOST'].present?
# Specifies the header that your server uses for sending files. # Specifies the header that your server uses for sending files.
config.action_dispatch.x_sendfile_header = ENV['SENDFILE_HEADER'] if ENV['SENDFILE_HEADER'].present? config.action_dispatch.x_sendfile_header = ENV['SENDFILE_HEADER'] if ENV['SENDFILE_HEADER'].present?
@ -40,22 +36,32 @@ Rails.application.configure do
# Allow to specify public IP of reverse proxy if it's needed # Allow to specify public IP of reverse proxy if it's needed
config.action_dispatch.trusted_proxies = ENV['TRUSTED_PROXY_IP'].split(/(?:\s*,\s*|\s+)/).map { |item| IPAddr.new(item) } if ENV['TRUSTED_PROXY_IP'].present? config.action_dispatch.trusted_proxies = ENV['TRUSTED_PROXY_IP'].split(/(?:\s*,\s*|\s+)/).map { |item| IPAddr.new(item) } if ENV['TRUSTED_PROXY_IP'].present?
# 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. # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
config.force_ssl = true config.force_ssl = true
# Skip http-to-https redirect for the default health check endpoint.
config.ssl_options = { config.ssl_options = {
redirect: { redirect: {
exclude: ->(request) { request.path.start_with?('/health') || request.headers['Host'].end_with?('.onion') || request.headers['Host'].end_with?('.i2p') }, exclude: ->(request) { request.path.start_with?('/health') || request.headers['Host'].end_with?('.onion') || request.headers['Host'].end_with?('.i2p') },
}, },
} }
# Info include generic and useful information about system operation, but avoids logging too much # Log to STDOUT by default
# information to avoid inadvertent exposure of personally identifiable information (PII). If you config.logger = ActiveSupport::Logger.new($stdout)
# want to log everything, set the level to "debug". .tap { |logger| logger.formatter = ::Logger::Formatter.new }
config.log_level = ENV.fetch('RAILS_LOG_LEVEL', 'info').to_sym .then { |logger| ActiveSupport::TaggedLogging.new(logger) }
# Prepend all log lines with the following tags. # Prepend all log lines with the following tags.
config.log_tags = [:request_id] 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. # Use a different cache store in production.
config.cache_store = :redis_cache_store, REDIS_CACHE_PARAMS config.cache_store = :redis_cache_store, REDIS_CACHE_PARAMS
@ -70,9 +76,8 @@ Rails.application.configure do
# config.action_mailer.raise_delivery_errors = false # config.action_mailer.raise_delivery_errors = false
# Enable locale fallbacks for I18n (makes lookups for any locale fall back to # Enable locale fallbacks for I18n (makes lookups for any locale fall back to
# English when a translation cannot be found). # the I18n.default_locale when a translation cannot be found).
# This setting would typically be `true` to use the `I18n.default_locale`. # Default value is `true`, but some locales have missing data and would have errors
# Some locales are missing translation entries and would have errors:
# https://github.com/mastodon/mastodon/pull/24727 # https://github.com/mastodon/mastodon/pull/24727
config.i18n.fallbacks = [:en] config.i18n.fallbacks = [:en]
@ -89,18 +94,8 @@ Rails.application.configure do
{ key: controller.signature_key_id } if controller.respond_to?(:signed_request?) && controller.signed_request? { key: controller.signature_key_id } if controller.respond_to?(:signed_request?) && controller.signed_request?
end end
# Use a different logger for distributed setups.
# require "syslog/logger"
# config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new "app-name")
# Log to STDOUT by default
config.logger = ActiveSupport::Logger.new($stdout)
.tap { |logger| logger.formatter = ::Logger::Formatter.new }
.then { |logger| ActiveSupport::TaggedLogging.new(logger) }
# Do not dump schema after migrations. # Do not dump schema after migrations.
config.active_record.dump_schema_after_migration = false config.active_record.dump_schema_after_migration = false
config.action_mailer.perform_caching = false config.action_mailer.perform_caching = false
# E-mails # E-mails

View file

@ -19,14 +19,15 @@ Rails.application.configure do
# loading is working properly before deploying your code. # loading is working properly before deploying your code.
config.eager_load = ENV['CI'].present? config.eager_load = ENV['CI'].present?
config.assets_digest = false # 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}" }
# Show full error reports and disable caching. # 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.action_controller.perform_caching = false
config.cache_store = :memory_store config.cache_store = :memory_store
# Raise exceptions instead of rendering exception templates. # Render exception templates for rescuable exceptions and raise for other exceptions.
config.action_dispatch.show_exceptions = :rescuable config.action_dispatch.show_exceptions = :rescuable
# Disable request forgery protection in test environment. # Disable request forgery protection in test environment.
@ -41,6 +42,10 @@ Rails.application.configure do
# ActionMailer::Base.deliveries array. # ActionMailer::Base.deliveries array.
config.action_mailer.delivery_method = :test 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. # Print deprecation notices to the stderr.
config.active_support.deprecation = :stderr config.active_support.deprecation = :stderr
@ -58,7 +63,6 @@ Rails.application.configure do
# Raise exceptions for disallowed deprecations. # Raise exceptions for disallowed deprecations.
config.active_support.disallowed_deprecation = :raise config.active_support.disallowed_deprecation = :raise
config.i18n.default_locale = :en
config.i18n.fallbacks = true config.i18n.fallbacks = true
# Tell Active Support which deprecation messages to disallow. # Tell Active Support which deprecation messages to disallow.
@ -70,7 +74,7 @@ Rails.application.configure do
# Annotate rendered view with file names. # Annotate rendered view with file names.
# config.action_view.annotate_rendered_view_with_filenames = true # config.action_view.annotate_rendered_view_with_filenames = true
# Raise error when a before_action's only/except options reference missing actions # Raise error when a before_action's only/except options reference missing actions.
config.action_controller.raise_on_missing_callback_actions = true config.action_controller.raise_on_missing_callback_actions = true
end end

View file

@ -0,0 +1,72 @@
# frozen_string_literal: true
# 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

View file

@ -11,7 +11,7 @@ namespace :tests do
'3_3_0' => 2020_12_18_054746, '3_3_0' => 2020_12_18_054746,
}.each do |release, version| }.each do |release, version|
ActiveRecord::Tasks::DatabaseTasks ActiveRecord::Tasks::DatabaseTasks
.migration_connection .migration_connection_pool
.migration_context .migration_context
.migrate(version) .migrate(version)
Rake::Task["tests:migrations:populate_v#{release}"] Rake::Task["tests:migrations:populate_v#{release}"]

View file

@ -13,7 +13,7 @@ describe Admin::SystemCheck::DatabaseSchemaCheck do
context 'when database needs migration' do context 'when database needs migration' do
before do before do
context = instance_double(ActiveRecord::MigrationContext, needs_migration?: true) context = instance_double(ActiveRecord::MigrationContext, needs_migration?: true)
allow(ActiveRecord::Base.connection).to receive(:migration_context).and_return(context) allow(ActiveRecord::Base.connection_pool).to receive(:migration_context).and_return(context)
end end
it 'returns false' do it 'returns false' do
@ -24,7 +24,7 @@ describe Admin::SystemCheck::DatabaseSchemaCheck do
context 'when database does not need migration' do context 'when database does not need migration' do
before do before do
context = instance_double(ActiveRecord::MigrationContext, needs_migration?: false) context = instance_double(ActiveRecord::MigrationContext, needs_migration?: false)
allow(ActiveRecord::Base.connection).to receive(:migration_context).and_return(context) allow(ActiveRecord::Base.connection_pool).to receive(:migration_context).and_return(context)
end end
it 'returns true' do it 'returns true' do