feeds_vacuum_spec.rb 1017 B

123456789101112131415161718192021222324252627282930
  1. require 'rails_helper'
  2. RSpec.describe Vacuum::FeedsVacuum do
  3. subject { described_class.new }
  4. describe '#perform' do
  5. let!(:active_user) { Fabricate(:user, current_sign_in_at: 2.days.ago) }
  6. let!(:inactive_user) { Fabricate(:user, current_sign_in_at: 22.days.ago) }
  7. before do
  8. redis.zadd(feed_key_for(inactive_user), 1, 1)
  9. redis.zadd(feed_key_for(active_user), 1, 1)
  10. redis.zadd(feed_key_for(inactive_user, 'reblogs'), 2, 2)
  11. redis.sadd(feed_key_for(inactive_user, 'reblogs:2'), 3)
  12. subject.perform
  13. end
  14. it 'clears feeds of inactive users and lists' do
  15. expect(redis.zcard(feed_key_for(inactive_user))).to eq 0
  16. expect(redis.zcard(feed_key_for(active_user))).to eq 1
  17. expect(redis.exists?(feed_key_for(inactive_user, 'reblogs'))).to be false
  18. expect(redis.exists?(feed_key_for(inactive_user, 'reblogs:2'))).to be false
  19. end
  20. end
  21. def feed_key_for(user, subtype = nil)
  22. FeedManager.instance.key(:home, user.account_id, subtype)
  23. end
  24. end