From b73932461f9251b39546f3a92b619ce3266680f6 Mon Sep 17 00:00:00 2001 From: Matt Jankowski Date: Wed, 21 Feb 2024 11:58:19 -0500 Subject: [PATCH] Add basic coverage for `CreateFeaturedTagService` class (#29321) --- .../create_featured_tag_service_spec.rb | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 spec/services/create_featured_tag_service_spec.rb diff --git a/spec/services/create_featured_tag_service_spec.rb b/spec/services/create_featured_tag_service_spec.rb new file mode 100644 index 000000000..29a7c5b30 --- /dev/null +++ b/spec/services/create_featured_tag_service_spec.rb @@ -0,0 +1,31 @@ +# frozen_string_literal: true + +require 'rails_helper' + +RSpec.describe CreateFeaturedTagService do + describe '#call' do + let(:tag) { 'test' } + + context 'with a local account' do + let(:account) { Fabricate(:account, domain: nil) } + + it 'creates a new featured tag and distributes' do + expect { subject.call(account, tag) } + .to change(FeaturedTag, :count).by(1) + expect(ActivityPub::AccountRawDistributionWorker) + .to have_enqueued_sidekiq_job(anything, account.id) + end + end + + context 'with a remote account' do + let(:account) { Fabricate(:account, domain: 'host.example') } + + it 'creates a new featured tag and does not distributes' do + expect { subject.call(account, tag) } + .to change(FeaturedTag, :count).by(1) + expect(ActivityPub::AccountRawDistributionWorker) + .to_not have_enqueued_sidekiq_job + end + end + end +end