0
0
Fork 0

Misc coverage improvements for validators (#23928)

This commit is contained in:
Matt Jankowski 2023-03-04 11:00:00 -05:00 committed by GitHub
parent 2f606ba122
commit c40d5e5a8f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 41 additions and 3 deletions

View file

@ -41,6 +41,22 @@ describe EmailMxValidator do
expect(user.errors).to_not have_received(:add)
end
it 'adds an error if the TagManager fails to normalize domain' do
double = instance_double(TagManager)
allow(TagManager).to receive(:instance).and_return(double)
allow(double).to receive(:normalize_domain).with('example.com').and_raise(Addressable::URI::InvalidURIError)
user = double(email: 'foo@example.com', errors: double(add: nil))
subject.validate(user)
expect(user.errors).to have_received(:add)
end
it 'adds an error if the domain email portion is blank' do
user = double(email: 'foo@', errors: double(add: nil))
subject.validate(user)
expect(user.errors).to have_received(:add)
end
it 'adds an error if the email domain name contains empty labels' do
resolver = double