You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
mastodon/spec/validators/user_email_validator_spec.rb

28 lines
805 B
Ruby

# frozen_string_literal: true
require 'rails_helper'
RSpec.describe UserEmailValidator do
subject { Fabricate.build :user, confirmed_at: nil }
let(:email_address) { 'info@host.example' }
context 'when email provider is blocked' do
before { Fabricate :email_domain_block, domain: 'host.example' }
it { is_expected.to_not allow_value(email_address).for(:email).with_message(:blocked) }
end
context 'when email provider is not blocked' do
it { is_expected.to allow_value(email_address).for(:email) }
end
context 'when canonical email address is blocked' do
let(:other_user) { Fabricate(:user, email: 'i.n.f.o@host.example') }
before { other_user.account.suspend! }
it { is_expected.to_not allow_value(email_address).for(:email).with_message(:taken) }
end
end