1
0
mirror of https://github.com/mastodon/mastodon synced 2024-11-23 22:56:20 +09:00

Reference constants from account validation specs (#30634)

This commit is contained in:
Matt Jankowski 2024-06-10 11:03:41 -04:00 committed by GitHub
parent 28f9a8f2ec
commit 92b3004bf3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -768,20 +768,20 @@ RSpec.describe Account do
expect(account).to model_have_error_on_field(:username)
end
it 'is invalid if the username is longer than 30 characters' do
account = Fabricate.build(:account, username: Faker::Lorem.characters(number: 31))
it 'is invalid if the username is longer than the character limit' do
account = Fabricate.build(:account, username: username_over_limit)
account.valid?
expect(account).to model_have_error_on_field(:username)
end
it 'is invalid if the display name is longer than 30 characters' do
account = Fabricate.build(:account, display_name: Faker::Lorem.characters(number: 31))
it 'is invalid if the display name is longer than the character limit' do
account = Fabricate.build(:account, display_name: username_over_limit)
account.valid?
expect(account).to model_have_error_on_field(:display_name)
end
it 'is invalid if the note is longer than 500 characters' do
account = Fabricate.build(:account, note: Faker::Lorem.characters(number: 501))
it 'is invalid if the note is longer than the character limit' do
account = Fabricate.build(:account, note: account_note_over_limit)
account.valid?
expect(account).to model_have_error_on_field(:note)
end
@ -814,24 +814,32 @@ RSpec.describe Account do
expect(account).to model_have_error_on_field(:username)
end
it 'is valid even if the username is longer than 30 characters' do
account = Fabricate.build(:account, domain: 'domain', username: Faker::Lorem.characters(number: 31))
it 'is valid even if the username is longer than the character limit' do
account = Fabricate.build(:account, domain: 'domain', username: username_over_limit)
account.valid?
expect(account).to_not model_have_error_on_field(:username)
end
it 'is valid even if the display name is longer than 30 characters' do
account = Fabricate.build(:account, domain: 'domain', display_name: Faker::Lorem.characters(number: 31))
it 'is valid even if the display name is longer than the character limit' do
account = Fabricate.build(:account, domain: 'domain', display_name: username_over_limit)
account.valid?
expect(account).to_not model_have_error_on_field(:display_name)
end
it 'is valid even if the note is longer than 500 characters' do
account = Fabricate.build(:account, domain: 'domain', note: Faker::Lorem.characters(number: 501))
it 'is valid even if the note is longer than the character limit' do
account = Fabricate.build(:account, domain: 'domain', note: account_note_over_limit)
account.valid?
expect(account).to_not model_have_error_on_field(:note)
end
end
def username_over_limit
'a' * described_class::USERNAME_LENGTH_LIMIT * 2
end
def account_note_over_limit
'a' * described_class::NOTE_LENGTH_LIMIT * 2
end
end
describe 'scopes' do