Add retention policy for cached content and media (#19232)
This commit is contained in:
parent
3e0999cd11
commit
5c9abdeff1
30 changed files with 559 additions and 135 deletions
|
@ -1,26 +0,0 @@
|
|||
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
|
||||
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)
|
||||
|
||||
subject.perform
|
||||
|
||||
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
|
||||
end
|
||||
|
||||
def feed_key_for(user, subtype = nil)
|
||||
FeedManager.instance.key(:home, user.account_id, subtype)
|
||||
end
|
||||
end
|
|
@ -1,15 +0,0 @@
|
|||
require 'rails_helper'
|
||||
|
||||
describe Scheduler::MediaCleanupScheduler do
|
||||
subject { described_class.new }
|
||||
|
||||
let!(:old_media) { Fabricate(:media_attachment, account_id: nil, created_at: 10.days.ago) }
|
||||
let!(:new_media) { Fabricate(:media_attachment, account_id: nil, created_at: 1.hour.ago) }
|
||||
|
||||
it 'removes old media records' do
|
||||
subject.perform
|
||||
|
||||
expect { old_media.reload }.to raise_error(ActiveRecord::RecordNotFound)
|
||||
expect(new_media.reload).to be_persisted
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue