remote_account_refresh_worker_spec.rb 948 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. # frozen_string_literal: true
  2. require 'rails_helper'
  3. RSpec.describe RemoteAccountRefreshWorker do
  4. let(:worker) { described_class.new }
  5. let(:service) { instance_double(ActivityPub::FetchRemoteAccountService, call: true) }
  6. describe '#perform' do
  7. before { stub_service }
  8. let(:account) { Fabricate(:account, domain: 'host.example') }
  9. it 'sends the status to the service' do
  10. worker.perform(account.id)
  11. expect(service).to have_received(:call).with(account.uri)
  12. end
  13. it 'returns nil for non-existent record' do
  14. result = worker.perform(123_123_123)
  15. expect(result).to be_nil
  16. end
  17. it 'returns nil for a local record' do
  18. account = Fabricate :account, domain: nil
  19. result = worker.perform(account)
  20. expect(result).to be_nil
  21. end
  22. def stub_service
  23. allow(ActivityPub::FetchRemoteAccountService)
  24. .to receive(:new)
  25. .and_return(service)
  26. end
  27. end
  28. end