remove_domains_from_followers_service_spec.rb 1.0 KB

12345678910111213141516171819202122232425262728
  1. # frozen_string_literal: true
  2. require 'rails_helper'
  3. RSpec.describe RemoveDomainsFromFollowersService do
  4. describe '#call' do
  5. context 'with account followers' do
  6. let(:account) { Fabricate(:account, domain: nil) }
  7. let(:good_domain_account) { Fabricate(:account, domain: 'good.example', protocol: :activitypub) }
  8. let(:bad_domain_account) { Fabricate(:account, domain: 'bad.example', protocol: :activitypub) }
  9. before do
  10. Fabricate :follow, target_account: account, account: good_domain_account
  11. Fabricate :follow, target_account: account, account: bad_domain_account
  12. end
  13. it 'removes followers from supplied domains and sends a notification' do
  14. subject.call(account, ['bad.example'])
  15. expect(account.followers)
  16. .to include(good_domain_account)
  17. .and not_include(bad_domain_account)
  18. expect(ActivityPub::DeliveryWorker)
  19. .to have_enqueued_sidekiq_job(anything, account.id, bad_domain_account.inbox_url)
  20. end
  21. end
  22. end
  23. end