publish_scheduled_announcement_worker_spec.rb 1.1 KB

1234567891011121314151617181920212223242526
  1. # frozen_string_literal: true
  2. require 'rails_helper'
  3. describe PublishScheduledAnnouncementWorker do
  4. subject { described_class.new }
  5. let!(:remote_account) { Fabricate(:account, domain: 'domain.com', username: 'foo', uri: 'https://domain.com/users/foo') }
  6. let!(:remote_status) { Fabricate(:status, uri: 'https://domain.com/users/foo/12345', account: remote_account) }
  7. let!(:local_status) { Fabricate(:status) }
  8. let(:scheduled_announcement) { Fabricate(:announcement, text: "rebooting very soon, see #{ActivityPub::TagManager.instance.uri_for(remote_status)} and #{ActivityPub::TagManager.instance.uri_for(local_status)}") }
  9. describe 'perform' do
  10. before do
  11. service = instance_double(FetchRemoteStatusService)
  12. allow(FetchRemoteStatusService).to receive(:new).and_return(service)
  13. allow(service).to receive(:call).with('https://domain.com/users/foo/12345') { remote_status.reload }
  14. subject.perform(scheduled_announcement.id)
  15. end
  16. it 'updates the linked statuses' do
  17. expect(scheduled_announcement.reload.status_ids).to eq [remote_status.id, local_status.id]
  18. end
  19. end
  20. end