Improve spec coverage for collection of workers/
classes (#27874)
This commit is contained in:
parent
0a6ec048a8
commit
155fb84141
16 changed files with 460 additions and 8 deletions
18
spec/workers/activitypub/post_upgrade_worker_spec.rb
Normal file
18
spec/workers/activitypub/post_upgrade_worker_spec.rb
Normal file
|
@ -0,0 +1,18 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
describe ActivityPub::PostUpgradeWorker do
|
||||
let(:worker) { described_class.new }
|
||||
|
||||
describe '#perform' do
|
||||
let(:domain) { 'host.example' }
|
||||
|
||||
it 'updates relevant values' do
|
||||
account = Fabricate(:account, domain: domain, last_webfingered_at: 1.day.ago, protocol: :ostatus)
|
||||
worker.perform(domain)
|
||||
|
||||
expect(account.reload.last_webfingered_at).to be_nil
|
||||
end
|
||||
end
|
||||
end
|
|
@ -0,0 +1,29 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
describe ActivityPub::SynchronizeFeaturedTagsCollectionWorker do
|
||||
let(:worker) { described_class.new }
|
||||
let(:service) { instance_double(ActivityPub::FetchFeaturedTagsCollectionService, call: true) }
|
||||
|
||||
describe '#perform' do
|
||||
before do
|
||||
allow(ActivityPub::FetchFeaturedTagsCollectionService).to receive(:new).and_return(service)
|
||||
end
|
||||
|
||||
let(:account) { Fabricate(:account) }
|
||||
let(:url) { 'https://host.example' }
|
||||
|
||||
it 'sends the account and url to the service' do
|
||||
worker.perform(account.id, url)
|
||||
|
||||
expect(service).to have_received(:call).with(account, url)
|
||||
end
|
||||
|
||||
it 'returns true for non-existent record' do
|
||||
result = worker.perform(123_123_123, url)
|
||||
|
||||
expect(result).to be(true)
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue