You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

27 lines
1.1 KiB

  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