about summary refs log tree commit diff
path: root/spec/services/purge_domain_service_spec.rb
diff options
context:
space:
mode:
authorClaire <claire.github-309c@sitedethib.com>2021-12-18 13:17:37 +0100
committerGitHub <noreply@github.com>2021-12-18 13:17:37 +0100
commit3b9a6049adf3ee6844a81622c297dd893836f79d (patch)
treefaf39c54064077baa984998a589803ecb7ecf230 /spec/services/purge_domain_service_spec.rb
parentfec4ed507466617ef34304b7d00d0383e8a958bb (diff)
parente061ea5f71109edbbf7869265f443448cace4f60 (diff)
Merge pull request #1650 from ClearlyClaire/glitch-soc/merge-upstream
Merge upstream changes
Diffstat (limited to 'spec/services/purge_domain_service_spec.rb')
-rw-r--r--spec/services/purge_domain_service_spec.rb27
1 files changed, 27 insertions, 0 deletions
diff --git a/spec/services/purge_domain_service_spec.rb b/spec/services/purge_domain_service_spec.rb
new file mode 100644
index 000000000..59285f126
--- /dev/null
+++ b/spec/services/purge_domain_service_spec.rb
@@ -0,0 +1,27 @@
+require 'rails_helper'
+
+RSpec.describe PurgeDomainService, type: :service do
+  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')) }
+
+  subject { PurgeDomainService.new }
+
+  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