mirror of
https://github.com/mastodon/mastodon.git
synced 2024-12-23 00:30:57 +01:00
Add basic coverage for RemoveFeaturedTagService
class (#29328)
This commit is contained in:
parent
6342ddd698
commit
7c7dfe7de3
1 changed files with 37 additions and 0 deletions
37
spec/services/remove_featured_tag_service_spec.rb
Normal file
37
spec/services/remove_featured_tag_service_spec.rb
Normal file
|
@ -0,0 +1,37 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe RemoveFeaturedTagService do
|
||||
describe '#call' do
|
||||
context 'with a featured tag' do
|
||||
let(:featured_tag) { Fabricate(:featured_tag) }
|
||||
|
||||
context 'when called by a local account' do
|
||||
let(:account) { Fabricate(:account, domain: nil) }
|
||||
|
||||
it 'destroys the featured tag and sends a distribution' do
|
||||
subject.call(account, featured_tag)
|
||||
|
||||
expect { featured_tag.reload }
|
||||
.to raise_error(ActiveRecord::RecordNotFound)
|
||||
expect(ActivityPub::AccountRawDistributionWorker)
|
||||
.to have_enqueued_sidekiq_job(anything, account.id)
|
||||
end
|
||||
end
|
||||
|
||||
context 'when called by a non local account' do
|
||||
let(:account) { Fabricate(:account, domain: 'host.example') }
|
||||
|
||||
it 'destroys the featured tag and does not send a distribution' do
|
||||
subject.call(account, featured_tag)
|
||||
|
||||
expect { featured_tag.reload }
|
||||
.to raise_error(ActiveRecord::RecordNotFound)
|
||||
expect(ActivityPub::AccountRawDistributionWorker)
|
||||
.to_not have_enqueued_sidekiq_job
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue