]> cat aescling's git repositories - mastodon.git/commitdiff
Prepare Mastodon for zeitwerk autoloader (#15917)
authorClaire <claire.github-309c@sitedethib.com>
Fri, 19 Mar 2021 01:42:43 +0000 (02:42 +0100)
committerGitHub <noreply@github.com>
Fri, 19 Mar 2021 01:42:43 +0000 (02:42 +0100)
* Prepare Mastodon for zeitwerk autoloader (Rails 6)

Add inflections and rename/move a few classes.

In particular, app/lib/exceptions.rb and app/lib/sanitize_config.rb
were manually loaded while still in autoload paths.

* Add inflection for Url → URL

15 files changed:
app/lib/formatter.rb
app/validators/url_validator.rb
config/application.rb
config/initializers/inflections.rb
db/migrate/20160223165723_add_url_to_statuses.rb
db/migrate/20160223165855_add_url_to_accounts.rb
db/migrate/20160322193748_add_avatar_remote_url_to_accounts.rb
db/migrate/20170318214217_add_header_remote_url_to_accounts.rb
db/migrate/20171130000000_add_embed_url_to_preview_cards.rb
db/migrate/20180304013859_add_featured_collection_url_to_accounts.rb
db/migrate/20200529214050_add_devices_url_to_accounts.rb
lib/exceptions.rb [moved from app/lib/exceptions.rb with 100% similarity]
lib/sanitize_ext/sanitize_config.rb [moved from app/lib/sanitize_config.rb with 100% similarity]
spec/lib/sanitize_config_spec.rb
spec/validators/url_validator_spec.rb

index 6fb5d541997adb1367140a5add11aaa03df797dc..2611bcbae01e95d3ad6e5fe3d271e563cb24efce 100644 (file)
@@ -1,7 +1,6 @@
 # frozen_string_literal: true
 
 require 'singleton'
-require_relative './sanitize_config'
 
 class Formatter
   include Singleton
index d95a03fbf86cda5494459f1c45cfe4eb642fe60a..f50abbe246e748b8299a9366ad5f4e8101f9a355 100644 (file)
@@ -1,6 +1,6 @@
 # frozen_string_literal: true
 
-class UrlValidator < ActiveModel::EachValidator
+class URLValidator < ActiveModel::EachValidator
   def validate_each(record, attribute, value)
     record.errors.add(attribute, I18n.t('applications.invalid_url')) unless compliant?(value)
   end
index 116eaf29d40f3428d69a020caffe8a516c6201c5..0960247b3a771dee1fa801a279a4b58b8a303a6d 100644 (file)
@@ -6,8 +6,9 @@ require 'rails/all'
 # you've limited to :test, :development, or :production.
 Bundler.require(*Rails.groups)
 
-require_relative '../app/lib/exceptions'
+require_relative '../lib/exceptions'
 require_relative '../lib/enumerable'
+require_relative '../lib/sanitize_ext/sanitize_config'
 require_relative '../lib/redis/namespace_extensions'
 require_relative '../lib/paperclip/url_generator_extensions'
 require_relative '../lib/paperclip/attachment_extensions'
index ebb7541ebaba27ca7db1dc5b6030c28a664855ab..9bc9a54b2d5757bcaa7324fdb2d4c623df408aa6 100644 (file)
@@ -20,6 +20,10 @@ ActiveSupport::Inflector.inflections(:en) do |inflect|
   inflect.acronym 'JsonLd'
   inflect.acronym 'NodeInfo'
   inflect.acronym 'Ed25519'
+  inflect.acronym 'TOC'
+  inflect.acronym 'RSS'
+  inflect.acronym 'REST'
+  inflect.acronym 'URL'
 
   inflect.singular 'data', 'data'
 end
index 80f4b3289e5bb51d3dd2b4b11383927bfc543bfe..fee7f9c59fab2f7fb055a09a0822ff0c38b156f5 100644 (file)
@@ -1,4 +1,4 @@
-class AddUrlToStatuses < ActiveRecord::Migration[4.2]
+class AddURLToStatuses < ActiveRecord::Migration[4.2]
   def change
     add_column :statuses, :url, :string, null: true, default: nil
   end
index c81b1c64fc7034f5c51348b894cb0d87127bbb82..a4db8814afc14274fea1c49d4f48d89b39541691 100644 (file)
@@ -1,4 +1,4 @@
-class AddUrlToAccounts < ActiveRecord::Migration[4.2]
+class AddURLToAccounts < ActiveRecord::Migration[4.2]
   def change
     add_column :accounts, :url, :string, null: true, default: nil
   end
index f9c213d9b47e6ffabe78879377d46b24690d6712..0792863a373c73c0949b65dc90f4fcefbeacb980 100644 (file)
@@ -1,4 +1,4 @@
-class AddAvatarRemoteUrlToAccounts < ActiveRecord::Migration[4.2]
+class AddAvatarRemoteURLToAccounts < ActiveRecord::Migration[4.2]
   def change
     add_column :accounts, :avatar_remote_url, :string, null: true, default: nil
   end
index 0ba38d3e00135fadaa90d2b1ff1bc93bf9cfca95..20c9659880915a12a69d3e1fc41c4462f2f4022a 100644 (file)
@@ -1,4 +1,4 @@
-class AddHeaderRemoteUrlToAccounts < ActiveRecord::Migration[5.0]
+class AddHeaderRemoteURLToAccounts < ActiveRecord::Migration[5.0]
   def change
     add_column :accounts, :header_remote_url, :string, null: false, default: ''
   end
index d19c0091bcd83539d9b5afce8f47848bfb2e930c..8fcabef9fd5d9a5a79295f98fb332559c1b72acf 100644 (file)
@@ -1,6 +1,6 @@
 require Rails.root.join('lib', 'mastodon', 'migration_helpers')
 
-class AddEmbedUrlToPreviewCards < ActiveRecord::Migration[5.1]
+class AddEmbedURLToPreviewCards < ActiveRecord::Migration[5.1]
   include Mastodon::MigrationHelpers
 
   disable_ddl_transaction!
index e0b8ed5cc199478d8f77f9d0cd5c620a016140ad..1964b512166e2b05209280b30b4fd4bb74bea295 100644 (file)
@@ -1,4 +1,4 @@
-class AddFeaturedCollectionUrlToAccounts < ActiveRecord::Migration[5.1]
+class AddFeaturedCollectionURLToAccounts < ActiveRecord::Migration[5.1]
   def change
     add_column :accounts, :featured_collection_url, :string
   end
index 564877e5dcbca45de611203ec2f77f1571a61619..1323f8df7e7eccff42c2ab7f4ac1e0e26ee8c631 100644 (file)
@@ -1,4 +1,4 @@
-class AddDevicesUrlToAccounts < ActiveRecord::Migration[5.2]
+class AddDevicesURLToAccounts < ActiveRecord::Migration[5.2]
   def change
     add_column :accounts, :devices_url, :string
   end
similarity index 100%
rename from app/lib/exceptions.rb
rename to lib/exceptions.rb
index d66302e6449eca185bb399cd8f89e7bb4e2dd48e..747d81158da4547f8aa3251a282d07c9098c902e 100644 (file)
@@ -1,7 +1,6 @@
 # frozen_string_literal: true
 
 require 'rails_helper'
-require Rails.root.join('app', 'lib', 'sanitize_config.rb')
 
 describe Sanitize::Config do
   describe '::MASTODON_STRICT' do
index e8d0e6494690aceebc1c7c9bc6e297c6137f3af9..a44878a44f8c7ac13c95cc66ae502ca57e5fc5d6 100644 (file)
@@ -2,7 +2,7 @@
 
 require 'rails_helper'
 
-RSpec.describe UrlValidator, type: :validator do
+RSpec.describe URLValidator, type: :validator do
   describe '#validate_each' do
     before do
       allow(validator).to receive(:compliant?).with(value) { compliant }