refollow_worker_spec.rb 1.0 KB

12345678910111213141516171819202122232425262728293031
  1. # frozen_string_literal: true
  2. require 'rails_helper'
  3. RSpec.describe RefollowWorker do
  4. subject { described_class.new }
  5. let(:account) { Fabricate(:account, domain: 'example.org', protocol: :activitypub) }
  6. let(:alice) { Fabricate(:account, domain: nil, username: 'alice') }
  7. let(:bob) { Fabricate(:account, domain: nil, username: 'bob') }
  8. describe 'perform' do
  9. let(:service) { instance_double(FollowService) }
  10. before do
  11. allow(FollowService).to receive(:new).and_return(service)
  12. allow(service).to receive(:call)
  13. alice.follow!(account, reblogs: true)
  14. bob.follow!(account, reblogs: false)
  15. end
  16. it 'calls FollowService for local followers' do
  17. result = subject.perform(account.id)
  18. expect(result).to be_nil
  19. expect(service).to have_received(:call).with(alice, account, reblogs: true, notify: false, languages: nil, bypass_limit: true)
  20. expect(service).to have_received(:call).with(bob, account, reblogs: false, notify: false, languages: nil, bypass_limit: true)
  21. end
  22. end
  23. end