mirror of
https://git.kescher.at/CatCatNya/catstodon.git
synced 2024-11-29 00:31:37 +01:00
Add coverage for Account#prepare_contents
callback (#31748)
This commit is contained in:
parent
b265a654d7
commit
ba9fd1c32e
1 changed files with 24 additions and 0 deletions
|
@ -723,6 +723,30 @@ RSpec.describe Account do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
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 'Normalizations' do
|
||||||
describe 'username' do
|
describe 'username' do
|
||||||
it { is_expected.to normalize(:username).from(" \u3000bob \t \u00a0 \n ").to('bob') }
|
it { is_expected.to normalize(:username).from(" \u3000bob \t \u00a0 \n ").to('bob') }
|
||||||
|
|
Loading…
Reference in a new issue