mirror of
https://github.com/mastodon/mastodon.git
synced 2024-12-22 09:08:24 +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)
|
expect(account).to model_have_error_on_field(:username)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'is invalid if the username is longer than 30 characters' do
|
it 'is invalid if the username is longer than the character limit' do
|
||||||
account = Fabricate.build(:account, username: Faker::Lorem.characters(number: 31))
|
account = Fabricate.build(:account, username: username_over_limit)
|
||||||
account.valid?
|
account.valid?
|
||||||
expect(account).to model_have_error_on_field(:username)
|
expect(account).to model_have_error_on_field(:username)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'is invalid if the display name is longer than 30 characters' do
|
it 'is invalid if the display name is longer than the character limit' do
|
||||||
account = Fabricate.build(:account, display_name: Faker::Lorem.characters(number: 31))
|
account = Fabricate.build(:account, display_name: username_over_limit)
|
||||||
account.valid?
|
account.valid?
|
||||||
expect(account).to model_have_error_on_field(:display_name)
|
expect(account).to model_have_error_on_field(:display_name)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'is invalid if the note is longer than 500 characters' do
|
it 'is invalid if the note is longer than the character limit' do
|
||||||
account = Fabricate.build(:account, note: Faker::Lorem.characters(number: 501))
|
account = Fabricate.build(:account, note: account_note_over_limit)
|
||||||
account.valid?
|
account.valid?
|
||||||
expect(account).to model_have_error_on_field(:note)
|
expect(account).to model_have_error_on_field(:note)
|
||||||
end
|
end
|
||||||
|
@ -814,24 +814,32 @@ RSpec.describe Account do
|
||||||
expect(account).to model_have_error_on_field(:username)
|
expect(account).to model_have_error_on_field(:username)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'is valid even if the username is longer than 30 characters' do
|
it 'is valid even if the username is longer than the character limit' do
|
||||||
account = Fabricate.build(:account, domain: 'domain', username: Faker::Lorem.characters(number: 31))
|
account = Fabricate.build(:account, domain: 'domain', username: username_over_limit)
|
||||||
account.valid?
|
account.valid?
|
||||||
expect(account).to_not model_have_error_on_field(:username)
|
expect(account).to_not model_have_error_on_field(:username)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'is valid even if the display name is longer than 30 characters' do
|
it 'is valid even if the display name is longer than the character limit' do
|
||||||
account = Fabricate.build(:account, domain: 'domain', display_name: Faker::Lorem.characters(number: 31))
|
account = Fabricate.build(:account, domain: 'domain', display_name: username_over_limit)
|
||||||
account.valid?
|
account.valid?
|
||||||
expect(account).to_not model_have_error_on_field(:display_name)
|
expect(account).to_not model_have_error_on_field(:display_name)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'is valid even if the note is longer than 500 characters' do
|
it 'is valid even if the note is longer than the character limit' do
|
||||||
account = Fabricate.build(:account, domain: 'domain', note: Faker::Lorem.characters(number: 501))
|
account = Fabricate.build(:account, domain: 'domain', note: account_note_over_limit)
|
||||||
account.valid?
|
account.valid?
|
||||||
expect(account).to_not model_have_error_on_field(:note)
|
expect(account).to_not model_have_error_on_field(:note)
|
||||||
end
|
end
|
||||||
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
|
end
|
||||||
|
|
||||||
describe 'scopes' do
|
describe 'scopes' do
|
||||||
|
|
Loading…
Reference in a new issue