Normalize current_username on account migration

This commit is contained in:
Matt Jankowski 2025-11-12 12:26:08 -05:00
parent ed3710e58f
commit a176cc5cf1
2 changed files with 5 additions and 0 deletions

View File

@ -26,6 +26,7 @@ class AccountMigration < ApplicationRecord
before_validation :set_followers_count before_validation :set_followers_count
normalizes :acct, with: ->(acct) { acct.strip.delete_prefix('@') } normalizes :acct, with: ->(acct) { acct.strip.delete_prefix('@') }
normalizes :current_username, with: ->(value) { value.strip.delete_prefix('@') }
validates :acct, presence: true, domain: { acct: true } validates :acct, presence: true, domain: { acct: true }
validate :validate_migration_cooldown validate :validate_migration_cooldown

View File

@ -7,6 +7,10 @@ RSpec.describe AccountMigration do
describe 'acct' do describe 'acct' do
it { is_expected.to normalize(:acct).from(' @username@domain ').to('username@domain') } it { is_expected.to normalize(:acct).from(' @username@domain ').to('username@domain') }
end end
describe 'current_username' do
it { is_expected.to normalize(:current_username).from(' @username ').to('username') }
end
end end
describe 'Validations' do describe 'Validations' do