purge_domain_service_spec.rb 1.1 KB

123456789101112131415161718192021222324252627
  1. require 'rails_helper'
  2. RSpec.describe PurgeDomainService, type: :service do
  3. let!(:old_account) { Fabricate(:account, domain: 'obsolete.org') }
  4. let!(:old_status1) { Fabricate(:status, account: old_account) }
  5. let!(:old_status2) { Fabricate(:status, account: old_account) }
  6. let!(:old_attachment) { Fabricate(:media_attachment, account: old_account, status: old_status2, file: attachment_fixture('attachment.jpg')) }
  7. subject { PurgeDomainService.new }
  8. describe 'for a suspension' do
  9. before do
  10. subject.call('obsolete.org')
  11. end
  12. it 'removes the remote accounts\'s statuses and media attachments' do
  13. expect { old_account.reload }.to raise_exception ActiveRecord::RecordNotFound
  14. expect { old_status1.reload }.to raise_exception ActiveRecord::RecordNotFound
  15. expect { old_status2.reload }.to raise_exception ActiveRecord::RecordNotFound
  16. expect { old_attachment.reload }.to raise_exception ActiveRecord::RecordNotFound
  17. end
  18. it 'refreshes instances view' do
  19. expect(Instance.where(domain: 'obsolete.org').exists?).to be false
  20. end
  21. end
  22. end