after_block_domain_from_account_service_spec.rb 838 B

123456789101112131415161718192021222324252627
  1. # frozen_string_literal: true
  2. require 'rails_helper'
  3. RSpec.describe AfterBlockDomainFromAccountService, type: :service do
  4. subject { described_class.new }
  5. let!(:wolf) { Fabricate(:account, username: 'wolf', domain: 'evil.org', inbox_url: 'https://evil.org/inbox', protocol: :activitypub) }
  6. let!(:alice) { Fabricate(:account, username: 'alice') }
  7. before do
  8. stub_jsonld_contexts!
  9. allow(ActivityPub::DeliveryWorker).to receive(:perform_async)
  10. end
  11. it 'purge followers from blocked domain' do
  12. wolf.follow!(alice)
  13. subject.call(alice, 'evil.org')
  14. expect(wolf.following?(alice)).to be false
  15. end
  16. it 'sends Reject->Follow to followers from blocked domain' do
  17. wolf.follow!(alice)
  18. subject.call(alice, 'evil.org')
  19. expect(ActivityPub::DeliveryWorker).to have_received(:perform_async).once
  20. end
  21. end