mirror of
https://github.com/mastodon/mastodon.git
synced 2024-11-20 03:25:17 +01:00
Reduced repeated setup in PurgeDomainService
spec (#28786)
This commit is contained in:
parent
07e10e3747
commit
6c5a2d51bc
@ -5,25 +5,25 @@ require 'rails_helper'
|
|||||||
RSpec.describe PurgeDomainService, type: :service do
|
RSpec.describe PurgeDomainService, type: :service do
|
||||||
subject { described_class.new }
|
subject { described_class.new }
|
||||||
|
|
||||||
let!(:old_account) { Fabricate(:account, domain: 'obsolete.org') }
|
let(:domain) { 'obsolete.org' }
|
||||||
let!(:old_status_plain) { Fabricate(:status, account: old_account) }
|
let!(:account) { Fabricate(:account, domain: domain) }
|
||||||
let!(:old_status_with_attachment) { Fabricate(:status, account: old_account) }
|
let!(:status_plain) { Fabricate(:status, account: account) }
|
||||||
let!(:old_attachment) { Fabricate(:media_attachment, account: old_account, status: old_status_with_attachment, file: attachment_fixture('attachment.jpg')) }
|
let!(:status_with_attachment) { Fabricate(:status, account: account) }
|
||||||
|
let!(:attachment) { Fabricate(:media_attachment, account: account, status: status_with_attachment, file: attachment_fixture('attachment.jpg')) }
|
||||||
|
|
||||||
describe 'for a suspension' do
|
describe 'for a suspension' do
|
||||||
before do
|
it 'refreshes instance view and removes associated records' do
|
||||||
subject.call('obsolete.org')
|
expect { subject.call(domain) }
|
||||||
|
.to change { domain_instance_exists }.from(true).to(false)
|
||||||
|
|
||||||
|
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
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'removes the remote accounts\'s statuses and media attachments' do
|
def domain_instance_exists
|
||||||
expect { old_account.reload }.to raise_exception ActiveRecord::RecordNotFound
|
Instance.exists?(domain: domain)
|
||||||
expect { old_status_plain.reload }.to raise_exception ActiveRecord::RecordNotFound
|
|
||||||
expect { old_status_with_attachment.reload }.to raise_exception ActiveRecord::RecordNotFound
|
|
||||||
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
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user