mirror of
https://github.com/mastodon/mastodon.git
synced 2024-12-18 07:38:42 +00:00
Reference constants from account validation specs (#30634)
This commit is contained in:
parent
28f9a8f2ec
commit
92b3004bf3
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue