about summary refs log tree commit diff
path: root/spec/models
diff options
context:
space:
mode:
authorClaire <claire.github-309c@sitedethib.com>2022-08-25 06:15:55 +0200
committerGitHub <noreply@github.com>2022-08-25 06:15:55 +0200
commit4be626734dfe5d5bb550b117d966aa3f93d0ef38 (patch)
treeab558edfd645052e92881137fdd95a66c1e4eb03 /spec/models
parent5a3d09dc8e30198b4d8d921ef0b1ba0a35fe01d9 (diff)
parent448ed92f76981f40d6faf48ed9d798ee716a04b2 (diff)
Merge pull request #1827 from ClearlyClaire/glitch-soc/merge-upstream
Merge upstream changes
Diffstat (limited to 'spec/models')
-rw-r--r--spec/models/email_domain_block_spec.rb27
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