diff options
author | Claire <claire.github-309c@sitedethib.com> | 2022-08-25 05:07:39 +0200 |
---|---|---|
committer | Claire <claire.github-309c@sitedethib.com> | 2022-08-25 05:07:39 +0200 |
commit | 2d1d4210f9d394ea8e7357df08f8ca2cc925384a (patch) | |
tree | a5c69693d11b59a673b1981ea2d85bbc17991c42 /spec/models/email_domain_block_spec.rb | |
parent | 5a3d09dc8e30198b4d8d921ef0b1ba0a35fe01d9 (diff) | |
parent | 861b35dd54d266bc0a40b3cacb28e5b82ff6faaa (diff) |
Merge branch 'main' into glitch-soc/merge-upstream
Diffstat (limited to 'spec/models/email_domain_block_spec.rb')
-rw-r--r-- | spec/models/email_domain_block_spec.rb | 27 |
1 files changed, 20 insertions, 7 deletions
diff --git a/spec/models/email_domain_block_spec.rb b/spec/models/email_domain_block_spec.rb index 567a32c32..e23116888 100644 --- a/spec/models/email_domain_block_spec.rb +++ b/spec/models/email_domain_block_spec.rb @@ -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 |