statuses_vacuum_spec.rb 1.3 KB

123456789101112131415161718192021222324252627282930313233343536
  1. require 'rails_helper'
  2. RSpec.describe Vacuum::StatusesVacuum do
  3. let(:retention_period) { 7.days }
  4. let(:remote_account) { Fabricate(:account, domain: 'example.com') }
  5. subject { described_class.new(retention_period) }
  6. describe '#perform' do
  7. let!(:remote_status_old) { Fabricate(:status, account: remote_account, created_at: (retention_period + 2.days).ago) }
  8. let!(:remote_status_recent) { Fabricate(:status, account: remote_account, created_at: (retention_period - 2.days).ago) }
  9. let!(:local_status_old) { Fabricate(:status, created_at: (retention_period + 2.days).ago) }
  10. let!(:local_status_recent) { Fabricate(:status, created_at: (retention_period - 2.days).ago) }
  11. before do
  12. subject.perform
  13. end
  14. it 'deletes remote statuses past the retention period' do
  15. expect { remote_status_old.reload }.to raise_error ActiveRecord::RecordNotFound
  16. end
  17. it 'does not delete local statuses past the retention period' do
  18. expect { local_status_old.reload }.to_not raise_error
  19. end
  20. it 'does not delete remote statuses within the retention period' do
  21. expect { remote_status_recent.reload }.to_not raise_error
  22. end
  23. it 'does not delete local statuses within the retention period' do
  24. expect { local_status_recent.reload }.to_not raise_error
  25. end
  26. end
  27. end