闭社主体 forked from https://github.com/tootsuite/mastodon
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

26 lines
991 B

  1. require 'rails_helper'
  2. describe Scheduler::FeedCleanupScheduler do
  3. subject { described_class.new }
  4. let!(:active_user) { Fabricate(:user, current_sign_in_at: 2.days.ago) }
  5. let!(:inactive_user) { Fabricate(:user, current_sign_in_at: 22.days.ago) }
  6. it 'clears feeds of inactives' do
  7. Redis.current.zadd(feed_key_for(inactive_user), 1, 1)
  8. Redis.current.zadd(feed_key_for(active_user), 1, 1)
  9. Redis.current.zadd(feed_key_for(inactive_user, 'reblogs'), 2, 2)
  10. Redis.current.sadd(feed_key_for(inactive_user, 'reblogs:2'), 3)
  11. subject.perform
  12. expect(Redis.current.zcard(feed_key_for(inactive_user))).to eq 0
  13. expect(Redis.current.zcard(feed_key_for(active_user))).to eq 1
  14. expect(Redis.current.exists(feed_key_for(inactive_user, 'reblogs'))).to be false
  15. expect(Redis.current.exists(feed_key_for(inactive_user, 'reblogs:2'))).to be false
  16. end
  17. def feed_key_for(user, subtype = nil)
  18. FeedManager.instance.key(:home, user.account_id, subtype)
  19. end
  20. end