about summary refs log tree commit diff
path: root/spec/validators
diff options
context:
space:
mode:
authorStarfall <us@starfall.systems>2021-05-11 11:19:04 -0500
committerStarfall <us@starfall.systems>2021-05-11 11:19:04 -0500
commitd56731a0b9d73c48bbfbced8732e25587ba892a4 (patch)
treed3830ce2e0292ce07336496e40882c222f455a33 /spec/validators
parent459a36ab7303db4ee59945b4b2121b25cc86eb38 (diff)
parentffc3f8eebe134ca9b18af73aa29eaa1627082e40 (diff)
Merge branch 'glitch'
Diffstat (limited to 'spec/validators')
-rw-r--r--spec/validators/blacklisted_email_validator_spec.rb29
1 files changed, 21 insertions, 8 deletions
diff --git a/spec/validators/blacklisted_email_validator_spec.rb b/spec/validators/blacklisted_email_validator_spec.rb
index 53b355a57..f7d5e01bc 100644
--- a/spec/validators/blacklisted_email_validator_spec.rb
+++ b/spec/validators/blacklisted_email_validator_spec.rb
@@ -9,23 +9,36 @@ RSpec.describe BlacklistedEmailValidator, type: :validator do
 
     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)
+      allow_any_instance_of(described_class).to receive(:blocked_email_provider?) { blocked_email }
     end
 
-    context 'blocked_email?' do
+    subject { described_class.new.validate(user); errors }
+
+    context 'when e-mail provider is blocked' do
       let(:blocked_email) { true }
 
-      it 'calls errors.add' do
-        expect(errors).to have_received(:add).with(:email, :blocked)
+      it 'adds error' do
+        expect(subject).to have_received(:add).with(:email, :blocked)
       end
     end
 
-    context '!blocked_email?' do
+    context 'when e-mail provider is not blocked' do
       let(:blocked_email) { false }
 
-      it 'not calls errors.add' do
-        expect(errors).not_to have_received(:add).with(:email, :blocked)
+      it 'does not add errors' do
+        expect(subject).not_to have_received(:add).with(:email, :blocked)
+      end
+
+      context 'when canonical e-mail is blocked' do
+        let(:other_user) { Fabricate(:user, email: 'i.n.f.o@mail.com') }
+
+        before do
+          other_user.account.suspend!
+        end
+
+        it 'adds error' do
+          expect(subject).to have_received(:add).with(:email, :taken)
+        end
       end
     end
   end