2017-05-22 10:36:21 -07:00
|
|
|
require 'rails_helper'
|
|
|
|
|
|
|
|
describe Scheduler::FeedCleanupScheduler do
|
|
|
|
subject { described_class.new }
|
|
|
|
|
|
|
|
let!(:active_user) { Fabricate(:user, current_sign_in_at: 2.days.ago) }
|
|
|
|
let!(:inactive_user) { Fabricate(:user, current_sign_in_at: 22.days.ago) }
|
|
|
|
|
|
|
|
it 'clears feeds of inactives' do
|
2022-04-28 08:47:34 -07:00
|
|
|
redis.zadd(feed_key_for(inactive_user), 1, 1)
|
|
|
|
redis.zadd(feed_key_for(active_user), 1, 1)
|
|
|
|
redis.zadd(feed_key_for(inactive_user, 'reblogs'), 2, 2)
|
|
|
|
redis.sadd(feed_key_for(inactive_user, 'reblogs:2'), 3)
|
2017-05-22 10:36:21 -07:00
|
|
|
|
|
|
|
subject.perform
|
2017-06-28 05:50:23 -07:00
|
|
|
|
2022-04-28 08:47:34 -07:00
|
|
|
expect(redis.zcard(feed_key_for(inactive_user))).to eq 0
|
|
|
|
expect(redis.zcard(feed_key_for(active_user))).to eq 1
|
|
|
|
expect(redis.exists?(feed_key_for(inactive_user, 'reblogs'))).to be false
|
|
|
|
expect(redis.exists?(feed_key_for(inactive_user, 'reblogs:2'))).to be false
|
2017-05-22 10:36:21 -07:00
|
|
|
end
|
|
|
|
|
2017-10-17 02:45:06 -07:00
|
|
|
def feed_key_for(user, subtype = nil)
|
|
|
|
FeedManager.instance.key(:home, user.account_id, subtype)
|
2017-05-22 10:36:21 -07:00
|
|
|
end
|
|
|
|
end
|