clear_domain_media_service_spec.rb 1.0 KB

12345678910111213141516171819202122232425
  1. # frozen_string_literal: true
  2. require 'rails_helper'
  3. RSpec.describe ClearDomainMediaService do
  4. subject { described_class.new }
  5. let!(:bad_account) { Fabricate(:account, username: 'badguy666', domain: 'evil.org') }
  6. let!(:bad_status_plain) { Fabricate(:status, account: bad_account, text: 'You suck') }
  7. let!(:bad_status_with_attachment) { Fabricate(:status, account: bad_account, text: 'Hahaha') }
  8. let!(:bad_attachment) { Fabricate(:media_attachment, account: bad_account, status: bad_status_with_attachment, file: attachment_fixture('attachment.jpg')) }
  9. describe 'for a silence with reject media' do
  10. before do
  11. subject.call(DomainBlock.create!(domain: 'evil.org', severity: :silence, reject_media: true))
  12. end
  13. it 'leaves the domains status and attachments, but clears media' do
  14. expect { bad_status_plain.reload }.to_not raise_error
  15. expect { bad_status_with_attachment.reload }.to_not raise_error
  16. expect { bad_attachment.reload }.to_not raise_error
  17. expect(bad_attachment.file.exists?).to be false
  18. end
  19. end
  20. end