Normalize current_username on account migration (#38183)
This commit is contained in:
1 parent
377952703c
commit
6416724f75
3 files changed
+42
-9
No files matched your search
@@ -7,6 +7,10 @@ RSpec.describe AccountMigration do
|
||||
describe 'acct' do
|
||||
it { is_expected.to normalize(:acct).from(' @username@domain ').to('username@domain') }
|
||||
end
|
||||
|
||||
describe 'current_username' do
|
||||
it { is_expected.to normalize(:current_username).from(' @username ').to('username') }
|
||||
end
|
||||
end
|
||||
|
||||
describe 'Validations' do
|
||||
|
||||
@@ -33,20 +33,36 @@ RSpec.describe 'Settings Migrations' do
|
||||
end
|
||||
|
||||
describe 'Creating migrations' do
|
||||
let(:user) { Fabricate(:user, password: '12345678') }
|
||||
let(:user) { Fabricate(:user, password:) }
|
||||
let(:password) { '12345678' }
|
||||
|
||||
before { sign_in(user) }
|
||||
|
||||
context 'when migration account is changed' do
|
||||
let(:acct) { Fabricate(:account, also_known_as: [ActivityPub::TagManager.instance.uri_for(user.account)]) }
|
||||
|
||||
it 'updates moved to account' do
|
||||
visit settings_migration_path
|
||||
context 'when user has encrypted password' do
|
||||
it 'updates moved to account' do
|
||||
visit settings_migration_path
|
||||
|
||||
expect { fill_in_and_submit }
|
||||
.to(change { user.account.reload.moved_to_account_id }.to(acct.id))
|
||||
expect(page)
|
||||
.to have_content(I18n.t('settings.migrate'))
|
||||
expect { fill_in_and_submit }
|
||||
.to(change { user.account.reload.moved_to_account_id }.to(acct.id))
|
||||
expect(page)
|
||||
.to have_content(I18n.t('settings.migrate'))
|
||||
end
|
||||
end
|
||||
|
||||
context 'when user has blank encrypted password value' do
|
||||
before { user.update! encrypted_password: '' }
|
||||
|
||||
it 'updates moved to account using at-username value' do
|
||||
visit settings_migration_path
|
||||
|
||||
expect { fill_in_and_submit_via_username("@#{user.account.username}") }
|
||||
.to(change { user.account.reload.moved_to_account_id }.to(acct.id))
|
||||
expect(page)
|
||||
.to have_content(I18n.t('settings.migrate'))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -92,8 +108,18 @@ RSpec.describe 'Settings Migrations' do
|
||||
|
||||
def fill_in_and_submit
|
||||
fill_in 'account_migration_acct', with: acct.username
|
||||
fill_in 'account_migration_current_password', with: '12345678'
|
||||
if block_given?
|
||||
yield
|
||||
else
|
||||
fill_in 'account_migration_current_password', with: password
|
||||
end
|
||||
click_on I18n.t('migrations.proceed_with_move')
|
||||
end
|
||||
|
||||
def fill_in_and_submit_via_username(username)
|
||||
fill_in_and_submit do
|
||||
fill_in 'account_migration_current_username', with: username
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in new issue
Block a user