2023-02-22 09:55:31 +09:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2021-12-18 07:01:21 +09:00
|
|
|
require 'rails_helper'
|
|
|
|
|
|
|
|
RSpec.describe PurgeDomainService, type: :service do
|
2023-06-06 20:58:33 +09:00
|
|
|
subject { described_class.new }
|
2023-02-20 13:24:14 +09:00
|
|
|
|
2021-12-18 07:01:21 +09:00
|
|
|
let!(:old_account) { Fabricate(:account, domain: 'obsolete.org') }
|
2023-06-14 23:44:37 +09:00
|
|
|
let!(:old_status_plain) { Fabricate(:status, account: old_account) }
|
|
|
|
let!(:old_status_with_attachment) { Fabricate(:status, account: old_account) }
|
|
|
|
let!(:old_attachment) { Fabricate(:media_attachment, account: old_account, status: old_status_with_attachment, file: attachment_fixture('attachment.jpg')) }
|
2021-12-18 07:01:21 +09:00
|
|
|
|
|
|
|
describe 'for a suspension' do
|
|
|
|
before do
|
|
|
|
subject.call('obsolete.org')
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'removes the remote accounts\'s statuses and media attachments' do
|
|
|
|
expect { old_account.reload }.to raise_exception ActiveRecord::RecordNotFound
|
2023-06-14 23:44:37 +09:00
|
|
|
expect { old_status_plain.reload }.to raise_exception ActiveRecord::RecordNotFound
|
|
|
|
expect { old_status_with_attachment.reload }.to raise_exception ActiveRecord::RecordNotFound
|
2021-12-18 07:01:21 +09:00
|
|
|
expect { old_attachment.reload }.to raise_exception ActiveRecord::RecordNotFound
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'refreshes instances view' do
|
|
|
|
expect(Instance.where(domain: 'obsolete.org').exists?).to be false
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|