Add coverage for model normalizations (#31734)
This commit is contained in:
parent
9ed1aab9b7
commit
14af5b47ac
10 changed files with 70 additions and 63 deletions
|
@ -723,14 +723,15 @@ RSpec.describe Account do
|
|||
end
|
||||
end
|
||||
|
||||
describe 'Normalizations' do
|
||||
describe 'username' do
|
||||
it { is_expected.to normalize(:username).from(" \u3000bob \t \u00a0 \n ").to('bob') }
|
||||
end
|
||||
end
|
||||
|
||||
describe 'validations' do
|
||||
it { is_expected.to validate_presence_of(:username) }
|
||||
|
||||
it 'squishes the username before validation' do
|
||||
account = Fabricate(:account, domain: nil, username: " \u3000bob \t \u00a0 \n ")
|
||||
expect(account.username).to eq 'bob'
|
||||
end
|
||||
|
||||
context 'when is local' do
|
||||
it 'is invalid if the username is not unique in case-insensitive comparison among local accounts' do
|
||||
_account = Fabricate(:account, username: 'the_doctor')
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue