statuses_vacuum_spec.rb 1.1 KB

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