about summary refs log tree commit diff
path: root/spec/lib
diff options
context:
space:
mode:
authorThibG <thib@sitedethib.com>2020-10-22 22:38:11 +0200
committerGitHub <noreply@github.com>2020-10-22 22:38:11 +0200
commit36e5c9d45be0e94216b5b92ea8749a00bb68e0e3 (patch)
tree3f5e2b47d242c4044f0cd69433501834399879d5 /spec/lib
parent29870d2be6c0e78132416b5561aba20d6ca3c746 (diff)
parent5c60f7eaedbc2dc6184f8b2a4d99f58fdbd5b26b (diff)
Merge pull request #1441 from ThibG/glitch-soc/merge-upstream
Merge upstream changes
Diffstat (limited to 'spec/lib')
-rw-r--r--spec/lib/fast_ip_map_spec.rb21
-rw-r--r--spec/lib/feed_manager_spec.rb1
2 files changed, 22 insertions, 0 deletions
diff --git a/spec/lib/fast_ip_map_spec.rb b/spec/lib/fast_ip_map_spec.rb
new file mode 100644
index 000000000..c66f64828
--- /dev/null
+++ b/spec/lib/fast_ip_map_spec.rb
@@ -0,0 +1,21 @@
+# frozen_string_literal: true
+
+require 'rails_helper'
+
+describe FastIpMap do
+  describe '#include?' do
+    subject { described_class.new([IPAddr.new('20.4.0.0/16'), IPAddr.new('145.22.30.0/24'), IPAddr.new('189.45.86.3')])}
+
+    it 'returns true for an exact match' do
+      expect(subject.include?(IPAddr.new('189.45.86.3'))).to be true
+    end
+
+    it 'returns true for a range match' do
+      expect(subject.include?(IPAddr.new('20.4.45.7'))).to be true
+    end
+
+    it 'returns false for no match' do
+      expect(subject.include?(IPAddr.new('145.22.40.64'))).to be false
+    end
+  end
+end
diff --git a/spec/lib/feed_manager_spec.rb b/spec/lib/feed_manager_spec.rb
index 22c9ff31b..78563ee94 100644
--- a/spec/lib/feed_manager_spec.rb
+++ b/spec/lib/feed_manager_spec.rb
@@ -108,6 +108,7 @@ RSpec.describe FeedManager do
 
       it 'returns false for status by followee mentioning another account' do
         bob.follow!(alice)
+        jeff.follow!(alice)
         status = PostStatusService.new.call(alice, text: 'Hey @jeff')
         expect(FeedManager.instance.filter?(:home, status, bob)).to be false
       end