purge_domain_service_spec.rb 1.2 KB

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