0
0
Fork 0

Fix spec descriptions around configurable limit values (#31079)

This commit is contained in:
Matt Jankowski 2024-07-22 04:02:31 -04:00 committed by GitHub
parent 5a60a3b80c
commit 6e4305de69
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 30 additions and 13 deletions

View file

@ -6,7 +6,7 @@ describe NoteLengthValidator do
subject { described_class.new(attributes: { note: true }, maximum: 500) }
describe '#validate' do
it 'adds an error when text is over 500 characters' do
it 'adds an error when text is over configured character limit' do
text = 'a' * 520
account = instance_double(Account, note: text, errors: activemodel_errors)
@ -14,16 +14,16 @@ describe NoteLengthValidator do
expect(account.errors).to have_received(:add)
end
it 'counts URLs as 23 characters flat' do
text = ('a' * 476) + " http://#{'b' * 30}.com/example"
it 'reduces calculated length of auto-linkable space-separated URLs' do
text = [starting_string, example_link].join(' ')
account = instance_double(Account, note: text, errors: activemodel_errors)
subject.validate_each(account, 'note', text)
expect(account.errors).to_not have_received(:add)
end
it 'does not count non-autolinkable URLs as 23 characters flat' do
text = ('a' * 476) + "http://#{'b' * 30}.com/example"
it 'does not reduce calculated length of non-autolinkable URLs' do
text = [starting_string, example_link].join
account = instance_double(Account, note: text, errors: activemodel_errors)
subject.validate_each(account, 'note', text)
@ -32,6 +32,14 @@ describe NoteLengthValidator do
private
def starting_string
'a' * 476
end
def example_link
"http://#{'b' * 30}.com/example"
end
def activemodel_errors
instance_double(ActiveModel::Errors, add: nil)
end