Specs for cleanup workers (#3235)
* Add spec files for feed and media cleanup workers * Add coverage for feed and media cleanup schedulers * Clean up feed and media cleanup workersth-downstream
parent
cc91569a92
commit
0eb8b00cc9
@ -0,0 +1,19 @@
|
||||
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
|
||||
expect_any_instance_of(Redis).to receive(:del).with(feed_key_for(inactive_user))
|
||||
expect_any_instance_of(Redis).not_to receive(:del).with(feed_key_for(active_user))
|
||||
|
||||
subject.perform
|
||||
end
|
||||
|
||||
def feed_key_for(user)
|
||||
FeedManager.instance.key(:home, user.account_id)
|
||||
end
|
||||
end
|
@ -0,0 +1,15 @@
|
||||
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…
Reference in new issue