2023-02-22 00:55:31 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2021-12-17 22:01:21 +00:00
|
|
|
require 'rails_helper'
|
|
|
|
|
2024-03-13 08:39:26 +00:00
|
|
|
RSpec.describe PurgeDomainService do
|
2023-06-06 11:58:33 +00:00
|
|
|
subject { described_class.new }
|
2023-02-20 04:24:14 +00:00
|
|
|
|
2024-01-18 10:07:49 +00:00
|
|
|
let(:domain) { 'obsolete.org' }
|
|
|
|
let!(:account) { Fabricate(:account, domain: domain) }
|
|
|
|
let!(:status_plain) { Fabricate(:status, account: account) }
|
|
|
|
let!(:status_with_attachment) { Fabricate(:status, account: account) }
|
|
|
|
let!(:attachment) { Fabricate(:media_attachment, account: account, status: status_with_attachment, file: attachment_fixture('attachment.jpg')) }
|
2021-12-17 22:01:21 +00:00
|
|
|
|
|
|
|
describe 'for a suspension' do
|
2024-01-18 10:07:49 +00:00
|
|
|
it 'refreshes instance view and removes associated records' do
|
|
|
|
expect { subject.call(domain) }
|
|
|
|
.to change { domain_instance_exists }.from(true).to(false)
|
2021-12-17 22:01:21 +00:00
|
|
|
|
2024-01-18 10:07:49 +00:00
|
|
|
expect { account.reload }.to raise_exception ActiveRecord::RecordNotFound
|
|
|
|
expect { status_plain.reload }.to raise_exception ActiveRecord::RecordNotFound
|
|
|
|
expect { status_with_attachment.reload }.to raise_exception ActiveRecord::RecordNotFound
|
|
|
|
expect { attachment.reload }.to raise_exception ActiveRecord::RecordNotFound
|
2021-12-17 22:01:21 +00:00
|
|
|
end
|
|
|
|
|
2024-01-18 10:07:49 +00:00
|
|
|
def domain_instance_exists
|
|
|
|
Instance.exists?(domain: domain)
|
2021-12-17 22:01:21 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|