~cytrogen/masto-fe

ref: 24015ef0cc84e7caffc4c02b9b7d5cdbdeb80002 masto-fe/spec/services/purge_domain_service_spec.rb -rw-r--r-- 1.1 KiB
24015ef0 — Daniel M Brasil Migrate to request specs in `/api/v1/domain_blocks` (#25414) 2 years ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# frozen_string_literal: true

require 'rails_helper'

RSpec.describe PurgeDomainService, type: :service do
  subject { described_class.new }

  let!(:old_account) { Fabricate(:account, domain: 'obsolete.org') }
  let!(:old_status1) { Fabricate(:status, account: old_account) }
  let!(:old_status2) { Fabricate(:status, account: old_account) }
  let!(:old_attachment) { Fabricate(:media_attachment, account: old_account, status: old_status2, file: attachment_fixture('attachment.jpg')) }

  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
      expect { old_status1.reload }.to raise_exception ActiveRecord::RecordNotFound
      expect { old_status2.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