forked from asonix/mastodon
* Increase DNS timeout from 1 second to 5 seconds for MX check 1 seconds is rather short when using a recursive DNS resolver which hasn't got a cached result already available. Use 5 seconds instead, which is the timeout value we use for outgoing HTTP queries. * Add more precise error messages for invalid e-mail addresses
32 lines
917 B
Ruby
32 lines
917 B
Ruby
# frozen_string_literal: true
|
|
|
|
require 'rails_helper'
|
|
|
|
RSpec.describe BlacklistedEmailValidator, type: :validator do
|
|
describe '#validate' do
|
|
let(:user) { double(email: 'info@mail.com', errors: errors) }
|
|
let(:errors) { double(add: nil) }
|
|
|
|
before do
|
|
allow(user).to receive(:valid_invitation?) { false }
|
|
allow_any_instance_of(described_class).to receive(:blocked_email?) { blocked_email }
|
|
described_class.new.validate(user)
|
|
end
|
|
|
|
context 'blocked_email?' do
|
|
let(:blocked_email) { true }
|
|
|
|
it 'calls errors.add' do
|
|
expect(errors).to have_received(:add).with(:email, I18n.t('users.blocked_email_provider'))
|
|
end
|
|
end
|
|
|
|
context '!blocked_email?' do
|
|
let(:blocked_email) { false }
|
|
|
|
it 'not calls errors.add' do
|
|
expect(errors).not_to have_received(:add).with(:email, I18n.t('users.blocked_email_provider'))
|
|
end
|
|
end
|
|
end
|
|
end
|