about summary refs log tree commit diff
path: root/spec/validators
diff options
context:
space:
mode:
authorClaire <claire.github-309c@sitedethib.com>2023-02-25 14:00:40 +0100
committerClaire <claire.github-309c@sitedethib.com>2023-02-25 14:00:40 +0100
commit4ed09276d5267181061dff438a0b10770db9f226 (patch)
treecb8f358d58669626332ea01bcf0186d08b5eac90 /spec/validators
parent45087c1092143e95dfcc85b6c9abc5c6c0a0a5c2 (diff)
parent730bb3e211a84a2f30e3e2bbeae3f77149824a68 (diff)
Merge branch 'main' into glitch-soc/merge-upstream
Conflicts:
- `.prettierignore`:
  Upstream added a line at the end of the file, while glitch-soc had its own
  extra lines.
  Took upstream's change.
- `CONTRIBUTING.md`:
  We have our custom CONTRIBUTING.md quoting upstream. Upstream made changes.
  Ported upstream changes.
- `app/controllers/application_controller.rb`:
  Upstream made code style changes in a method that is entirely replaced
  in glitch-soc.
  Ignored the change.
- `app/models/account.rb`:
  Code style changes textually close to glitch-soc-specific changes.
  Ported upstream changes.
- `lib/sanitize_ext/sanitize_config.rb`:
  Upstream code style changes.
  Ignored them.
Diffstat (limited to 'spec/validators')
-rw-r--r--spec/validators/blacklisted_email_validator_spec.rb8
-rw-r--r--spec/validators/disallowed_hashtags_validator_spec.rb6
-rw-r--r--spec/validators/email_mx_validator_spec.rb2
-rw-r--r--spec/validators/follow_limit_validator_spec.rb4
-rw-r--r--spec/validators/poll_validator_spec.rb4
-rw-r--r--spec/validators/status_length_validator_spec.rb4
-rw-r--r--spec/validators/unreserved_username_validator_spec.rb4
-rw-r--r--spec/validators/url_validator_spec.rb2
8 files changed, 17 insertions, 17 deletions
diff --git a/spec/validators/blacklisted_email_validator_spec.rb b/spec/validators/blacklisted_email_validator_spec.rb
index 351de0707..a642405ae 100644
--- a/spec/validators/blacklisted_email_validator_spec.rb
+++ b/spec/validators/blacklisted_email_validator_spec.rb
@@ -4,16 +4,16 @@ require 'rails_helper'
 
 RSpec.describe BlacklistedEmailValidator, type: :validator do
   describe '#validate' do
+    subject { described_class.new.validate(user); errors }
+
     let(:user)   { double(email: 'info@mail.com', sign_up_ip: '1.2.3.4', errors: errors) }
     let(:errors) { double(add: nil) }
 
     before do
-      allow(user).to receive(:valid_invitation?) { false }
+      allow(user).to receive(:valid_invitation?).and_return(false)
       allow_any_instance_of(described_class).to receive(:blocked_email_provider?) { blocked_email }
     end
 
-    subject { described_class.new.validate(user); errors }
-
     context 'when e-mail provider is blocked' do
       let(:blocked_email) { true }
 
@@ -26,7 +26,7 @@ RSpec.describe BlacklistedEmailValidator, type: :validator do
       let(:blocked_email) { false }
 
       it 'does not add errors' do
-        expect(subject).not_to have_received(:add).with(:email, :blocked)
+        expect(subject).to_not have_received(:add).with(:email, :blocked)
       end
 
       context 'when canonical e-mail is blocked' do
diff --git a/spec/validators/disallowed_hashtags_validator_spec.rb b/spec/validators/disallowed_hashtags_validator_spec.rb
index 9deec0bb9..896fd4fc5 100644
--- a/spec/validators/disallowed_hashtags_validator_spec.rb
+++ b/spec/validators/disallowed_hashtags_validator_spec.rb
@@ -11,7 +11,7 @@ RSpec.describe DisallowedHashtagsValidator, type: :validator do
       described_class.new.validate(status)
     end
 
-    let(:status) { double(errors: errors, local?: local, reblog?: reblog, text: disallowed_tags.map { |x| '#' + x }.join(' ')) }
+    let(:status) { double(errors: errors, local?: local, reblog?: reblog, text: disallowed_tags.map { |x| "##{x}" }.join(' ')) }
     let(:errors) { double(add: nil) }
 
     context 'for a remote reblog' do
@@ -19,7 +19,7 @@ RSpec.describe DisallowedHashtagsValidator, type: :validator do
       let(:reblog) { true }
 
       it 'does not add errors' do
-        expect(errors).not_to have_received(:add).with(:text, any_args)
+        expect(errors).to_not have_received(:add).with(:text, any_args)
       end
     end
 
@@ -31,7 +31,7 @@ RSpec.describe DisallowedHashtagsValidator, type: :validator do
         let(:disallowed_tags) { [] }
 
         it 'does not add errors' do
-          expect(errors).not_to have_received(:add).with(:text, any_args)
+          expect(errors).to_not have_received(:add).with(:text, any_args)
         end
       end
 
diff --git a/spec/validators/email_mx_validator_spec.rb b/spec/validators/email_mx_validator_spec.rb
index 6640d6058..ffb6851d0 100644
--- a/spec/validators/email_mx_validator_spec.rb
+++ b/spec/validators/email_mx_validator_spec.rb
@@ -38,7 +38,7 @@ describe EmailMxValidator do
       allow(Resolv::DNS).to receive(:open).and_yield(resolver)
 
       subject.validate(user)
-      expect(user.errors).not_to have_received(:add)
+      expect(user.errors).to_not have_received(:add)
     end
 
     it 'adds an error if the email domain name contains empty labels' do
diff --git a/spec/validators/follow_limit_validator_spec.rb b/spec/validators/follow_limit_validator_spec.rb
index cc8fbb631..94ba0c47f 100644
--- a/spec/validators/follow_limit_validator_spec.rb
+++ b/spec/validators/follow_limit_validator_spec.rb
@@ -22,7 +22,7 @@ RSpec.describe FollowLimitValidator, type: :validator do
       let(:_nil)    { true }
 
       it 'not calls errors.add' do
-        expect(errors).not_to have_received(:add).with(:base, any_args)
+        expect(errors).to_not have_received(:add).with(:base, any_args)
       end
     end
 
@@ -43,7 +43,7 @@ RSpec.describe FollowLimitValidator, type: :validator do
         let(:limit_reached) { false }
 
         it 'not calls errors.add' do
-          expect(errors).not_to have_received(:add).with(:base, any_args)
+          expect(errors).to_not have_received(:add).with(:base, any_args)
         end
       end
     end
diff --git a/spec/validators/poll_validator_spec.rb b/spec/validators/poll_validator_spec.rb
index a76c63ccc..f3f4b1288 100644
--- a/spec/validators/poll_validator_spec.rb
+++ b/spec/validators/poll_validator_spec.rb
@@ -15,14 +15,14 @@ RSpec.describe PollValidator, type: :validator do
     let(:expires_at) { 1.day.from_now }
 
     it 'have no errors' do
-      expect(errors).not_to have_received(:add)
+      expect(errors).to_not have_received(:add)
     end
 
     context 'expires just 5 min ago' do
       let(:expires_at) { 5.minutes.from_now }
 
       it 'not calls errors add' do
-        expect(errors).not_to have_received(:add)
+        expect(errors).to_not have_received(:add)
       end
     end
   end
diff --git a/spec/validators/status_length_validator_spec.rb b/spec/validators/status_length_validator_spec.rb
index 4c80a59e6..2cd369335 100644
--- a/spec/validators/status_length_validator_spec.rb
+++ b/spec/validators/status_length_validator_spec.rb
@@ -7,13 +7,13 @@ describe StatusLengthValidator do
     it 'does not add errors onto remote statuses' do
       status = double(local?: false)
       subject.validate(status)
-      expect(status).not_to receive(:errors)
+      expect(status).to_not receive(:errors)
     end
 
     it 'does not add errors onto local reblogs' do
       status = double(local?: false, reblog?: true)
       subject.validate(status)
-      expect(status).not_to receive(:errors)
+      expect(status).to_not receive(:errors)
     end
 
     it 'adds an error when content warning is over MAX_CHARS characters' do
diff --git a/spec/validators/unreserved_username_validator_spec.rb b/spec/validators/unreserved_username_validator_spec.rb
index e2f051b08..3c6f71c59 100644
--- a/spec/validators/unreserved_username_validator_spec.rb
+++ b/spec/validators/unreserved_username_validator_spec.rb
@@ -17,7 +17,7 @@ RSpec.describe UnreservedUsernameValidator, type: :validator do
       let(:username) { nil }
 
       it 'not calls errors.add' do
-        expect(errors).not_to have_received(:add).with(:username, any_args)
+        expect(errors).to_not have_received(:add).with(:username, any_args)
       end
     end
 
@@ -36,7 +36,7 @@ RSpec.describe UnreservedUsernameValidator, type: :validator do
         let(:reserved_username) { false }
 
         it 'not calls errors.add' do
-          expect(errors).not_to have_received(:add).with(:username, any_args)
+          expect(errors).to_not have_received(:add).with(:username, any_args)
         end
       end
     end
diff --git a/spec/validators/url_validator_spec.rb b/spec/validators/url_validator_spec.rb
index 85eadeb63..966261b50 100644
--- a/spec/validators/url_validator_spec.rb
+++ b/spec/validators/url_validator_spec.rb
@@ -27,7 +27,7 @@ RSpec.describe URLValidator, type: :validator do
       let(:compliant) { true }
 
       it 'not calls errors.add' do
-        expect(errors).not_to have_received(:add).with(attribute, any_args)
+        expect(errors).to_not have_received(:add).with(attribute, any_args)
       end
     end
   end