1
0

purge_domain_service_spec.rb 1.1 KB

1234567891011121314151617181920212223242526272829
  1. # frozen_string_literal: true
  2. require 'rails_helper'
  3. RSpec.describe PurgeDomainService do
  4. subject { described_class.new }
  5. let(:domain) { 'obsolete.org' }
  6. let!(:account) { Fabricate(:account, domain: domain) }
  7. let!(:status_plain) { Fabricate(:status, account: account) }
  8. let!(:status_with_attachment) { Fabricate(:status, account: account) }
  9. let!(:attachment) { Fabricate(:media_attachment, account: account, status: status_with_attachment, file: attachment_fixture('attachment.jpg')) }
  10. describe 'for a suspension' do
  11. it 'refreshes instance view and removes associated records' do
  12. expect { subject.call(domain) }
  13. .to change { domain_instance_exists }.from(true).to(false)
  14. expect { account.reload }.to raise_exception ActiveRecord::RecordNotFound
  15. expect { status_plain.reload }.to raise_exception ActiveRecord::RecordNotFound
  16. expect { status_with_attachment.reload }.to raise_exception ActiveRecord::RecordNotFound
  17. expect { attachment.reload }.to raise_exception ActiveRecord::RecordNotFound
  18. end
  19. def domain_instance_exists
  20. Instance.exists?(domain: domain)
  21. end
  22. end
  23. end