You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

26 lines
1.1 KiB

  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 = double
  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