1
0
Fork 0
mirror of https://github.com/mastodon/mastodon.git synced 2024-08-20 21:08:15 -07:00

Add basic coverage for UnfavouriteService class (#29329)

This commit is contained in:
Matt Jankowski 2024-02-22 05:48:42 -05:00 committed by GitHub
parent f70905f127
commit 6342ddd698
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -0,0 +1,36 @@
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe UnfavouriteService do
describe '#call' do
context 'with a favourited status' do
let(:status) { Fabricate(:status, account: account) }
let!(:favourite) { Fabricate(:favourite, status: status) }
context 'when the status account is local' do
let(:account) { Fabricate(:account, domain: nil) }
it 'destroys the favourite' do
subject.call(favourite.account, status)
expect { favourite.reload }
.to raise_error(ActiveRecord::RecordNotFound)
end
end
context 'when the status account is a remote activitypub account' do
let(:account) { Fabricate(:account, domain: 'host.example', protocol: :activitypub) }
it 'destroys the favourite and sends a notification' do
subject.call(favourite.account, status)
expect { favourite.reload }
.to raise_error(ActiveRecord::RecordNotFound)
expect(ActivityPub::DeliveryWorker)
.to have_enqueued_sidekiq_job(anything, favourite.account.id, status.account.inbox_url)
end
end
end
end
end