Merge remote-tracking branch 'parent/main' into upstream-20240906
This commit is contained in:
commit
f18eabfe75
689 changed files with 4369 additions and 2434 deletions
|
@ -3,6 +3,8 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.describe Account do
|
||||
include_examples 'Reviewable'
|
||||
|
||||
context 'with an account record' do
|
||||
subject { Fabricate(:account) }
|
||||
|
||||
|
@ -944,17 +946,38 @@ RSpec.describe Account do
|
|||
end
|
||||
end
|
||||
|
||||
describe 'validations' do
|
||||
it 'is invalid without a username' do
|
||||
account = Fabricate.build(:account, username: nil)
|
||||
account.valid?
|
||||
expect(account).to model_have_error_on_field(:username)
|
||||
describe '#prepare_contents' do
|
||||
subject { Fabricate.build :account, domain: domain, note: ' padded note ', display_name: ' padded name ' }
|
||||
|
||||
context 'with local account' do
|
||||
let(:domain) { nil }
|
||||
|
||||
it 'strips values' do
|
||||
expect { subject.valid? }
|
||||
.to change(subject, :note).to('padded note')
|
||||
.and(change(subject, :display_name).to('padded name'))
|
||||
end
|
||||
end
|
||||
|
||||
it 'squishes the username before validation' do
|
||||
account = Fabricate(:account, domain: nil, username: " \u3000bob \t \u00a0 \n ")
|
||||
expect(account.username).to eq 'bob'
|
||||
context 'with remote account' do
|
||||
let(:domain) { 'host.example' }
|
||||
|
||||
it 'preserves values' do
|
||||
expect { subject.valid? }
|
||||
.to not_change(subject, :note)
|
||||
.and(not_change(subject, :display_name))
|
||||
end
|
||||
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) }
|
||||
|
||||
context 'when is local' do
|
||||
it 'is invalid if the username is not unique in case-insensitive comparison among local accounts' do
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue