about summary refs log tree commit diff
path: root/spec/lib/feed_manager_spec.rb
diff options
context:
space:
mode:
authorThibG <thib@sitedethib.com>2020-07-22 15:39:36 +0200
committerGitHub <noreply@github.com>2020-07-22 15:39:36 +0200
commit4024952b58bacb94d2cb43fafddf0e97bea4c55c (patch)
treeb1c1e5cdb84606879d65ecceebe4cf665332379b /spec/lib/feed_manager_spec.rb
parent801e546ecc1efb4103232d8265229eb455a8dd5b (diff)
parentf8e315cd74d05a6878bbd018b20462daa0b5e660 (diff)
Merge pull request #1385 from ThibG/glitch-soc/merge-upstream
Merge upstream changes
Diffstat (limited to 'spec/lib/feed_manager_spec.rb')
-rw-r--r--spec/lib/feed_manager_spec.rb25
1 files changed, 25 insertions, 0 deletions
diff --git a/spec/lib/feed_manager_spec.rb b/spec/lib/feed_manager_spec.rb
index 705e577a6..40e8214b6 100644
--- a/spec/lib/feed_manager_spec.rb
+++ b/spec/lib/feed_manager_spec.rb
@@ -531,4 +531,29 @@ RSpec.describe FeedManager do
       expect(Redis.current).to have_received(:publish).with("timeline:#{receiver.id}", deletion)
     end
   end
+
+  describe '#clear_from_timeline' do
+    let(:account)          { Fabricate(:account) }
+    let(:followed_account) { Fabricate(:account) }
+    let(:target_account)   { Fabricate(:account) }
+    let(:status_1)         { Fabricate(:status, account: followed_account) }
+    let(:status_2)         { Fabricate(:status, account: target_account) }
+    let(:status_3)         { Fabricate(:status, account: followed_account, mentions: [Fabricate(:mention, account: target_account)]) }
+    let(:status_4)         { Fabricate(:status, mentions: [Fabricate(:mention, account: target_account)]) }
+    let(:status_5)         { Fabricate(:status, account: followed_account, reblog: status_4) }
+    let(:status_6)         { Fabricate(:status, account: followed_account, reblog: status_2) }
+    let(:status_7)         { Fabricate(:status, account: followed_account) }
+
+    before do
+      [status_1, status_3, status_5, status_6, status_7].each do |status|
+        Redis.current.zadd("feed:home:#{account.id}", status.id, status.id)
+      end
+    end
+
+    it 'correctly cleans the timeline' do
+      FeedManager.instance.clear_from_timeline(account, target_account)
+
+      expect(Redis.current.zrange("feed:home:#{account.id}", 0, -1)).to eq [status_1.id.to_s, status_7.id.to_s]
+    end
+  end
 end