2021-06-01 12:20:20 +00:00
|
|
|
# Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/
|
|
|
|
|
2019-11-21 15:49:14 +00:00
|
|
|
require 'rails_helper'
|
|
|
|
|
|
|
|
RSpec.describe EmailAddressValidation do
|
|
|
|
|
|
|
|
describe 'Valid email address' do
|
|
|
|
|
|
|
|
describe 'with dot in domain' do
|
|
|
|
|
|
|
|
describe 'with MX record' do
|
2019-11-21 16:39:24 +00:00
|
|
|
let(:email_address) { 'greetings@example.com' }
|
2019-11-21 15:49:14 +00:00
|
|
|
let(:email_address_validation) { described_class.new(email_address) }
|
|
|
|
|
|
|
|
it 'reports given email address' do
|
|
|
|
expect(email_address_validation.email_address).to eq(email_address)
|
|
|
|
expect(email_address_validation.to_s).to eq(email_address)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'reports email address as valid' do
|
|
|
|
expect(email_address_validation.valid_format?).to be(true)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'reports email address to have domain with MX record' do
|
|
|
|
expect(email_address_validation.valid_mx?).to be(true)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe 'without MX record' do
|
|
|
|
let(:email_address) { 'someone@this-is-probably-a-non-existent-domain.com.example' }
|
|
|
|
let(:email_address_validation) { described_class.new(email_address) }
|
|
|
|
|
|
|
|
it 'reports given email address' do
|
|
|
|
expect(email_address_validation.email_address).to eq(email_address)
|
|
|
|
expect(email_address_validation.to_s).to eq(email_address)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'reports email address as valid' do
|
|
|
|
expect(email_address_validation.valid_format?).to be(true)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'reports email address to have domain without MX record' do
|
|
|
|
expect(email_address_validation.valid_mx?).to be(false)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
describe 'without dot in domain' do
|
2019-11-21 16:39:24 +00:00
|
|
|
let(:email_address) { 'greetings@localhost' }
|
2019-11-21 15:49:14 +00:00
|
|
|
let(:email_address_validation) { described_class.new(email_address) }
|
|
|
|
|
|
|
|
it 'reports given email address' do
|
|
|
|
expect(email_address_validation.email_address).to eq(email_address)
|
|
|
|
expect(email_address_validation.to_s).to eq(email_address)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'reports email address as valid' do
|
|
|
|
expect(email_address_validation.valid_format?).to be(true)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'reports email address to have domain without MX record' do
|
|
|
|
expect(email_address_validation.valid_mx?).to be(false)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
describe 'Email address' do
|
|
|
|
|
|
|
|
describe 'without domain' do
|
|
|
|
let(:email_address) { 'zammad' }
|
|
|
|
let(:email_address_validation) { described_class.new(email_address) }
|
|
|
|
|
|
|
|
it 'reports given email address' do
|
|
|
|
expect(email_address_validation.email_address).to eq(email_address)
|
|
|
|
expect(email_address_validation.to_s).to eq(email_address)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'reports email address as invalid' do
|
|
|
|
expect(email_address_validation.valid_format?).to be(false)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'reports email address to have domain without MX record' do
|
|
|
|
expect(email_address_validation.valid_mx?).to be(false)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe 'with invalid domain format' do
|
2019-11-21 16:39:24 +00:00
|
|
|
let(:email_address) { 'greetings@example..com' }
|
2019-11-21 15:49:14 +00:00
|
|
|
let(:email_address_validation) { described_class.new(email_address) }
|
|
|
|
|
|
|
|
it 'reports given email address' do
|
|
|
|
expect(email_address_validation.email_address).to eq(email_address)
|
|
|
|
expect(email_address_validation.to_s).to eq(email_address)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'reports email address as invalid' do
|
|
|
|
expect(email_address_validation.valid_format?).to be(false)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'reports email address to have domain without MX record' do
|
|
|
|
expect(email_address_validation.valid_mx?).to be(false)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe 'which is empty' do
|
|
|
|
let(:email_address) { '' }
|
|
|
|
let(:email_address_validation) { described_class.new(email_address) }
|
|
|
|
|
|
|
|
it 'reports given email address' do
|
|
|
|
expect(email_address_validation.email_address).to eq(email_address)
|
|
|
|
expect(email_address_validation.to_s).to eq(email_address)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'reports email address as invalid' do
|
|
|
|
expect(email_address_validation.valid_format?).to be(false)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'reports email address to have domain without MX record' do
|
|
|
|
expect(email_address_validation.valid_mx?).to be(false)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|