0
0
Fork 0

Change e-mail domain blocks to match subdomains of blocked domains (#18979)

This commit is contained in:
Eugen Rochko 2022-08-24 19:00:55 +02:00 committed by GitHub
parent d83faa1a89
commit 0412a4d03e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 65 additions and 28 deletions

View file

@ -12,16 +12,29 @@ RSpec.describe EmailDomainBlock, type: :model do
let(:input) { nil }
context 'given an e-mail address' do
let(:input) { 'nyarn@example.com' }
let(:input) { "foo@#{domain}" }
it 'returns true if the domain is blocked' do
Fabricate(:email_domain_block, domain: 'example.com')
expect(EmailDomainBlock.block?(input)).to be true
context do
let(:domain) { 'example.com' }
it 'returns true if the domain is blocked' do
Fabricate(:email_domain_block, domain: 'example.com')
expect(EmailDomainBlock.block?(input)).to be true
end
it 'returns false if the domain is not blocked' do
Fabricate(:email_domain_block, domain: 'other-example.com')
expect(EmailDomainBlock.block?(input)).to be false
end
end
it 'returns false if the domain is not blocked' do
Fabricate(:email_domain_block, domain: 'other-example.com')
expect(EmailDomainBlock.block?(input)).to be false
context do
let(:domain) { 'mail.example.com' }
it 'returns true if it is a subdomain of a blocked domain' do
Fabricate(:email_domain_block, domain: 'example.com')
expect(described_class.block?(input)).to be true
end
end
end