about summary refs log tree commit diff
path: root/spec
diff options
context:
space:
mode:
authorAkihiko Odaki (@fn_aki@pawoo.net) <akihiko.odaki.4i@stu.hosei.ac.jp>2017-06-29 08:17:26 +0900
committerEugen Rochko <eugen@zeonfederated.com>2017-06-29 01:17:26 +0200
commit60b2b56d380c7cd3dc0ba54f4650cfdba568e38e (patch)
tree0b890b4bc713e350392e88f16e327886c5146bf7 /spec
parentb6a19e7b89fb4b32f35e810580a5aea7ff87addd (diff)
Reduce number of commands in FeedManager#trim (#3989)
Diffstat (limited to 'spec')
-rw-r--r--spec/lib/feed_manager_spec.rb13
1 files changed, 13 insertions, 0 deletions
diff --git a/spec/lib/feed_manager_spec.rb b/spec/lib/feed_manager_spec.rb
index bf474c354..4bdc96866 100644
--- a/spec/lib/feed_manager_spec.rb
+++ b/spec/lib/feed_manager_spec.rb
@@ -131,4 +131,17 @@ RSpec.describe FeedManager do
       end
     end
   end
+
+  describe '#push' do
+    it 'trims timelines if they will have more than FeedManager::MAX_ITEMS' do
+      account = Fabricate(:account)
+      status = Fabricate(:status)
+      members = FeedManager::MAX_ITEMS.times.map { |count| [count, count] }
+      Redis.current.zadd("feed:type:#{account.id}", members)
+
+      FeedManager.instance.push('type', account, status)
+
+      expect(Redis.current.zcard("feed:type:#{account.id}")).to eq FeedManager::MAX_ITEMS
+    end
+  end
 end