about summary refs log tree commit diff
path: root/spec/lib
diff options
context:
space:
mode:
authorThibG <thib@sitedethib.com>2019-09-19 00:22:39 +0200
committerGitHub <noreply@github.com>2019-09-19 00:22:39 +0200
commitfebcdad2e2c98aee62b55ee21bdf0debf7c6fd6b (patch)
tree1a99988dd7a46824527e59ee1861aa72ad7412ce /spec/lib
parentab646fac5f582fe9bef22d8b9a4995fbb4b42d7d (diff)
parent2ecc7106d7fc222ca84777fc279e9f46f80afd5a (diff)
Merge pull request #1221 from ThibG/glitch-soc/merge-upstream
Merge upstream changes
Diffstat (limited to 'spec/lib')
-rw-r--r--spec/lib/spam_check_spec.rb34
1 files changed, 22 insertions, 12 deletions
diff --git a/spec/lib/spam_check_spec.rb b/spec/lib/spam_check_spec.rb
index 9e0989216..4cae46111 100644
--- a/spec/lib/spam_check_spec.rb
+++ b/spec/lib/spam_check_spec.rb
@@ -86,23 +86,33 @@ RSpec.describe SpamCheck do
     end
 
     it 'returns true for duplicate statuses to the same recipient' do
-      status1 = status_with_html('@alice Hello')
-      described_class.new(status1).remember!
+      described_class::THRESHOLD.times do
+        status1 = status_with_html('@alice Hello')
+        described_class.new(status1).remember!
+      end
+
       status2 = status_with_html('@alice Hello')
       expect(described_class.new(status2).spam?).to be true
     end
 
     it 'returns true for duplicate statuses to different recipients' do
-      status1 = status_with_html('@alice Hello')
-      described_class.new(status1).remember!
+      described_class::THRESHOLD.times do
+        status1 = status_with_html('@alice Hello')
+        described_class.new(status1).remember!
+      end
+
       status2 = status_with_html('@bob Hello')
       expect(described_class.new(status2).spam?).to be true
     end
 
     it 'returns true for nearly identical statuses with random numbers' do
       source_text = 'Sodium, atomic number 11, was first isolated by Humphry Davy in 1807. A chemical component of salt, he named it Na in honor of the saltiest region on earth, North America.'
-      status1 = status_with_html('@alice ' + source_text + ' 1234')
-      described_class.new(status1).remember!
+
+      described_class::THRESHOLD.times do
+        status1 = status_with_html('@alice ' + source_text + ' 1234')
+        described_class.new(status1).remember!
+      end
+
       status2 = status_with_html('@bob ' + source_text + ' 9568')
       expect(described_class.new(status2).spam?).to be true
     end
@@ -140,9 +150,9 @@ RSpec.describe SpamCheck do
     let(:redis_key) { spam_check.send(:redis_key) }
 
     it 'remembers' do
-      expect do
-        spam_check.remember!
-      end.to change { Redis.current.exists(redis_key) }.from(false).to(true)
+      expect(Redis.current.exists(redis_key)).to be true
+      spam_check.remember!
+      expect(Redis.current.exists(redis_key)).to be true
     end
   end
 
@@ -156,9 +166,9 @@ RSpec.describe SpamCheck do
     end
 
     it 'resets' do
-      expect do
-        spam_check.reset!
-      end.to change { Redis.current.exists(redis_key) }.from(true).to(false)
+      expect(Redis.current.exists(redis_key)).to be true
+      spam_check.reset!
+      expect(Redis.current.exists(redis_key)).to be false
     end
   end