The code powering m.abunchtell.com https://m.abunchtell.com
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

34 lines
1.2 KiB

  1. require 'rails_helper'
  2. RSpec.describe BlockDomainService do
  3. let(:bad_account) { Fabricate(:account, username: 'badguy666', domain: 'evil.org') }
  4. let(:bad_status1) { Fabricate(:status, account: bad_account, text: 'You suck') }
  5. let(:bad_status2) { Fabricate(:status, account: bad_account, text: 'Hahaha') }
  6. let(:bad_attachment) { Fabricate(:media_attachment, account: bad_account, status: bad_status2, file: attachment_fixture('attachment.jpg')) }
  7. subject { BlockDomainService.new }
  8. before do
  9. bad_account
  10. bad_status1
  11. bad_status2
  12. bad_attachment
  13. subject.call(DomainBlock.create!(domain: 'evil.org', severity: :suspend))
  14. end
  15. it 'creates a domain block' do
  16. expect(DomainBlock.blocked?('evil.org')).to be true
  17. end
  18. it 'removes remote accounts from that domain' do
  19. expect(Account.find_remote('badguy666', 'evil.org').suspended?).to be true
  20. end
  21. it 'removes the remote accounts\'s statuses and media attachments' do
  22. expect { bad_status1.reload }.to raise_exception ActiveRecord::RecordNotFound
  23. expect { bad_status2.reload }.to raise_exception ActiveRecord::RecordNotFound
  24. expect { bad_attachment.reload }.to raise_exception ActiveRecord::RecordNotFound
  25. end
  26. end