From 39e7525c96962ad33b27d9cb4bd5fa8086060b75 Mon Sep 17 00:00:00 2001 From: Matt Jankowski Date: Sat, 4 Mar 2023 10:56:09 -0500 Subject: [PATCH] Add basic coverage for some worker jobs (#23943) --- .../admin/account_deletion_worker_spec.rb | 19 +++++++++++++++++++ spec/workers/cache_buster_worker_spec.rb | 19 +++++++++++++++++++ .../poll_expiration_notify_worker_spec.rb | 13 +++++++++++++ .../workers/post_process_media_worker_spec.rb | 13 +++++++++++++ spec/workers/push_conversation_worker_spec.rb | 13 +++++++++++++ .../push_encrypted_message_worker_spec.rb | 13 +++++++++++++ spec/workers/push_update_worker_spec.rb | 16 ++++++++++++++++ spec/workers/redownload_avatar_worker_spec.rb | 13 +++++++++++++ spec/workers/redownload_header_worker_spec.rb | 13 +++++++++++++ .../remove_featured_tag_worker_spec.rb | 15 +++++++++++++++ spec/workers/resolve_account_worker_spec.rb | 13 +++++++++++++ .../scheduler/indexing_scheduler_spec.rb | 13 +++++++++++++ .../instance_refresh_scheduler_spec.rb | 13 +++++++++++++ .../scheduler/ip_cleanup_scheduler_spec.rb | 13 +++++++++++++ .../scheduler/pghero_scheduler_spec.rb | 13 +++++++++++++ .../scheduled_statuses_scheduler_spec.rb | 13 +++++++++++++ .../suspended_user_cleanup_scheduler_spec.rb | 13 +++++++++++++ .../trends/refresh_scheduler_spec.rb | 13 +++++++++++++ .../review_notifications_scheduler_spec.rb | 13 +++++++++++++ .../scheduler/vacuum_scheduler_spec.rb | 13 +++++++++++++ .../unpublish_announcement_worker_spec.rb | 13 +++++++++++++ spec/workers/webhooks/delivery_worker_spec.rb | 13 +++++++++++++ 22 files changed, 303 insertions(+) create mode 100644 spec/workers/admin/account_deletion_worker_spec.rb create mode 100644 spec/workers/cache_buster_worker_spec.rb create mode 100644 spec/workers/poll_expiration_notify_worker_spec.rb create mode 100644 spec/workers/post_process_media_worker_spec.rb create mode 100644 spec/workers/push_conversation_worker_spec.rb create mode 100644 spec/workers/push_encrypted_message_worker_spec.rb create mode 100644 spec/workers/push_update_worker_spec.rb create mode 100644 spec/workers/redownload_avatar_worker_spec.rb create mode 100644 spec/workers/redownload_header_worker_spec.rb create mode 100644 spec/workers/remove_featured_tag_worker_spec.rb create mode 100644 spec/workers/resolve_account_worker_spec.rb create mode 100644 spec/workers/scheduler/indexing_scheduler_spec.rb create mode 100644 spec/workers/scheduler/instance_refresh_scheduler_spec.rb create mode 100644 spec/workers/scheduler/ip_cleanup_scheduler_spec.rb create mode 100644 spec/workers/scheduler/pghero_scheduler_spec.rb create mode 100644 spec/workers/scheduler/scheduled_statuses_scheduler_spec.rb create mode 100644 spec/workers/scheduler/suspended_user_cleanup_scheduler_spec.rb create mode 100644 spec/workers/scheduler/trends/refresh_scheduler_spec.rb create mode 100644 spec/workers/scheduler/trends/review_notifications_scheduler_spec.rb create mode 100644 spec/workers/scheduler/vacuum_scheduler_spec.rb create mode 100644 spec/workers/unpublish_announcement_worker_spec.rb create mode 100644 spec/workers/webhooks/delivery_worker_spec.rb diff --git a/spec/workers/admin/account_deletion_worker_spec.rb b/spec/workers/admin/account_deletion_worker_spec.rb new file mode 100644 index 000000000..631cab664 --- /dev/null +++ b/spec/workers/admin/account_deletion_worker_spec.rb @@ -0,0 +1,19 @@ +# frozen_string_literal: true + +require 'rails_helper' + +describe Admin::AccountDeletionWorker do + let(:worker) { described_class.new } + + describe 'perform' do + let(:account) { Fabricate(:account) } + let(:service) { instance_double(DeleteAccountService, call: true) } + + it 'calls delete account service' do + allow(DeleteAccountService).to receive(:new).and_return(service) + worker.perform(account.id) + + expect(service).to have_received(:call).with(account, { reserve_email: true, reserve_username: true }) + end + end +end diff --git a/spec/workers/cache_buster_worker_spec.rb b/spec/workers/cache_buster_worker_spec.rb new file mode 100644 index 000000000..adeb287fa --- /dev/null +++ b/spec/workers/cache_buster_worker_spec.rb @@ -0,0 +1,19 @@ +# frozen_string_literal: true + +require 'rails_helper' + +describe CacheBusterWorker do + let(:worker) { described_class.new } + + describe 'perform' do + let(:path) { 'https://example.com' } + let(:service) { instance_double(CacheBuster, bust: true) } + + it 'calls the cache buster' do + allow(CacheBuster).to receive(:new).and_return(service) + worker.perform(path) + + expect(service).to have_received(:bust).with(path) + end + end +end diff --git a/spec/workers/poll_expiration_notify_worker_spec.rb b/spec/workers/poll_expiration_notify_worker_spec.rb new file mode 100644 index 000000000..8229db815 --- /dev/null +++ b/spec/workers/poll_expiration_notify_worker_spec.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +require 'rails_helper' + +describe PollExpirationNotifyWorker do + let(:worker) { described_class.new } + + describe 'perform' do + it 'runs without error for missing record' do + expect { worker.perform(nil) }.to_not raise_error + end + end +end diff --git a/spec/workers/post_process_media_worker_spec.rb b/spec/workers/post_process_media_worker_spec.rb new file mode 100644 index 000000000..33072704b --- /dev/null +++ b/spec/workers/post_process_media_worker_spec.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +require 'rails_helper' + +describe PostProcessMediaWorker do + let(:worker) { described_class.new } + + describe 'perform' do + it 'runs without error for missing record' do + expect { worker.perform(nil) }.to_not raise_error + end + end +end diff --git a/spec/workers/push_conversation_worker_spec.rb b/spec/workers/push_conversation_worker_spec.rb new file mode 100644 index 000000000..5fbb4c685 --- /dev/null +++ b/spec/workers/push_conversation_worker_spec.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +require 'rails_helper' + +describe PushConversationWorker do + let(:worker) { described_class.new } + + describe 'perform' do + it 'runs without error for missing record' do + expect { worker.perform(nil) }.to_not raise_error + end + end +end diff --git a/spec/workers/push_encrypted_message_worker_spec.rb b/spec/workers/push_encrypted_message_worker_spec.rb new file mode 100644 index 000000000..3cd04ce7b --- /dev/null +++ b/spec/workers/push_encrypted_message_worker_spec.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +require 'rails_helper' + +describe PushEncryptedMessageWorker do + let(:worker) { described_class.new } + + describe 'perform' do + it 'runs without error for missing record' do + expect { worker.perform(nil) }.to_not raise_error + end + end +end diff --git a/spec/workers/push_update_worker_spec.rb b/spec/workers/push_update_worker_spec.rb new file mode 100644 index 000000000..c8f94fa82 --- /dev/null +++ b/spec/workers/push_update_worker_spec.rb @@ -0,0 +1,16 @@ +# frozen_string_literal: true + +require 'rails_helper' + +describe PushUpdateWorker do + let(:worker) { described_class.new } + + describe 'perform' do + it 'runs without error for missing record' do + account_id = nil + status_id = nil + + expect { worker.perform(account_id, status_id) }.to_not raise_error + end + end +end diff --git a/spec/workers/redownload_avatar_worker_spec.rb b/spec/workers/redownload_avatar_worker_spec.rb new file mode 100644 index 000000000..b44ae9f03 --- /dev/null +++ b/spec/workers/redownload_avatar_worker_spec.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +require 'rails_helper' + +describe RedownloadAvatarWorker do + let(:worker) { described_class.new } + + describe 'perform' do + it 'runs without error for missing record' do + expect { worker.perform(nil) }.to_not raise_error + end + end +end diff --git a/spec/workers/redownload_header_worker_spec.rb b/spec/workers/redownload_header_worker_spec.rb new file mode 100644 index 000000000..767ae7a5a --- /dev/null +++ b/spec/workers/redownload_header_worker_spec.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +require 'rails_helper' + +describe RedownloadHeaderWorker do + let(:worker) { described_class.new } + + describe 'perform' do + it 'runs without error for missing record' do + expect { worker.perform(nil) }.to_not raise_error + end + end +end diff --git a/spec/workers/remove_featured_tag_worker_spec.rb b/spec/workers/remove_featured_tag_worker_spec.rb new file mode 100644 index 000000000..a64bd0605 --- /dev/null +++ b/spec/workers/remove_featured_tag_worker_spec.rb @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +require 'rails_helper' + +describe RemoveFeaturedTagWorker do + let(:worker) { described_class.new } + + describe 'perform' do + it 'runs without error for missing record' do + account_id = nil + featured_tag_id = nil + expect { worker.perform(account_id, featured_tag_id) }.to_not raise_error + end + end +end diff --git a/spec/workers/resolve_account_worker_spec.rb b/spec/workers/resolve_account_worker_spec.rb new file mode 100644 index 000000000..6f3cff099 --- /dev/null +++ b/spec/workers/resolve_account_worker_spec.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +require 'rails_helper' + +describe ResolveAccountWorker do + let(:worker) { described_class.new } + + describe 'perform' do + it 'runs without error for missing record' do + expect { worker.perform(nil) }.to_not raise_error + end + end +end diff --git a/spec/workers/scheduler/indexing_scheduler_spec.rb b/spec/workers/scheduler/indexing_scheduler_spec.rb new file mode 100644 index 000000000..568f0fc84 --- /dev/null +++ b/spec/workers/scheduler/indexing_scheduler_spec.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +require 'rails_helper' + +describe Scheduler::IndexingScheduler do + let(:worker) { described_class.new } + + describe 'perform' do + it 'runs without error' do + expect { worker.perform }.to_not raise_error + end + end +end diff --git a/spec/workers/scheduler/instance_refresh_scheduler_spec.rb b/spec/workers/scheduler/instance_refresh_scheduler_spec.rb new file mode 100644 index 000000000..8f686a699 --- /dev/null +++ b/spec/workers/scheduler/instance_refresh_scheduler_spec.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +require 'rails_helper' + +describe Scheduler::InstanceRefreshScheduler do + let(:worker) { described_class.new } + + describe 'perform' do + it 'runs without error' do + expect { worker.perform }.to_not raise_error + end + end +end diff --git a/spec/workers/scheduler/ip_cleanup_scheduler_spec.rb b/spec/workers/scheduler/ip_cleanup_scheduler_spec.rb new file mode 100644 index 000000000..50af03011 --- /dev/null +++ b/spec/workers/scheduler/ip_cleanup_scheduler_spec.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +require 'rails_helper' + +describe Scheduler::IpCleanupScheduler do + let(:worker) { described_class.new } + + describe 'perform' do + it 'runs without error' do + expect { worker.perform }.to_not raise_error + end + end +end diff --git a/spec/workers/scheduler/pghero_scheduler_spec.rb b/spec/workers/scheduler/pghero_scheduler_spec.rb new file mode 100644 index 000000000..e404e5fe4 --- /dev/null +++ b/spec/workers/scheduler/pghero_scheduler_spec.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +require 'rails_helper' + +describe Scheduler::PgheroScheduler do + let(:worker) { described_class.new } + + describe 'perform' do + it 'runs without error' do + expect { worker.perform }.to_not raise_error + end + end +end diff --git a/spec/workers/scheduler/scheduled_statuses_scheduler_spec.rb b/spec/workers/scheduler/scheduled_statuses_scheduler_spec.rb new file mode 100644 index 000000000..13c853c62 --- /dev/null +++ b/spec/workers/scheduler/scheduled_statuses_scheduler_spec.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +require 'rails_helper' + +describe Scheduler::ScheduledStatusesScheduler do + let(:worker) { described_class.new } + + describe 'perform' do + it 'runs without error' do + expect { worker.perform }.to_not raise_error + end + end +end diff --git a/spec/workers/scheduler/suspended_user_cleanup_scheduler_spec.rb b/spec/workers/scheduler/suspended_user_cleanup_scheduler_spec.rb new file mode 100644 index 000000000..25f0e1fce --- /dev/null +++ b/spec/workers/scheduler/suspended_user_cleanup_scheduler_spec.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +require 'rails_helper' + +describe Scheduler::SuspendedUserCleanupScheduler do + let(:worker) { described_class.new } + + describe 'perform' do + it 'runs without error' do + expect { worker.perform }.to_not raise_error + end + end +end diff --git a/spec/workers/scheduler/trends/refresh_scheduler_spec.rb b/spec/workers/scheduler/trends/refresh_scheduler_spec.rb new file mode 100644 index 000000000..c0c5f032b --- /dev/null +++ b/spec/workers/scheduler/trends/refresh_scheduler_spec.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +require 'rails_helper' + +describe Scheduler::Trends::RefreshScheduler do + let(:worker) { described_class.new } + + describe 'perform' do + it 'runs without error' do + expect { worker.perform }.to_not raise_error + end + end +end diff --git a/spec/workers/scheduler/trends/review_notifications_scheduler_spec.rb b/spec/workers/scheduler/trends/review_notifications_scheduler_spec.rb new file mode 100644 index 000000000..cc971c24b --- /dev/null +++ b/spec/workers/scheduler/trends/review_notifications_scheduler_spec.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +require 'rails_helper' + +describe Scheduler::Trends::ReviewNotificationsScheduler do + let(:worker) { described_class.new } + + describe 'perform' do + it 'runs without error' do + expect { worker.perform }.to_not raise_error + end + end +end diff --git a/spec/workers/scheduler/vacuum_scheduler_spec.rb b/spec/workers/scheduler/vacuum_scheduler_spec.rb new file mode 100644 index 000000000..36ecc93d8 --- /dev/null +++ b/spec/workers/scheduler/vacuum_scheduler_spec.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +require 'rails_helper' + +describe Scheduler::VacuumScheduler do + let(:worker) { described_class.new } + + describe 'perform' do + it 'runs without error' do + expect { worker.perform }.to_not raise_error + end + end +end diff --git a/spec/workers/unpublish_announcement_worker_spec.rb b/spec/workers/unpublish_announcement_worker_spec.rb new file mode 100644 index 000000000..c742c30bc --- /dev/null +++ b/spec/workers/unpublish_announcement_worker_spec.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +require 'rails_helper' + +describe UnpublishAnnouncementWorker do + let(:worker) { described_class.new } + + describe 'perform' do + it 'runs without error for missing record' do + expect { worker.perform(nil) }.to_not raise_error + end + end +end diff --git a/spec/workers/webhooks/delivery_worker_spec.rb b/spec/workers/webhooks/delivery_worker_spec.rb new file mode 100644 index 000000000..daf8a3e28 --- /dev/null +++ b/spec/workers/webhooks/delivery_worker_spec.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +require 'rails_helper' + +describe Webhooks::DeliveryWorker do + let(:worker) { described_class.new } + + describe 'perform' do + it 'runs without error' do + expect { worker.perform(nil, nil) }.to_not raise_error + end + end +end