unfavourite_service_spec.rb 1.1 KB

123456789101112131415161718192021222324252627282930313233343536
  1. # frozen_string_literal: true
  2. require 'rails_helper'
  3. RSpec.describe UnfavouriteService do
  4. describe '#call' do
  5. context 'with a favourited status' do
  6. let(:status) { Fabricate(:status, account: account) }
  7. let!(:favourite) { Fabricate(:favourite, status: status) }
  8. context 'when the status account is local' do
  9. let(:account) { Fabricate(:account, domain: nil) }
  10. it 'destroys the favourite' do
  11. subject.call(favourite.account, status)
  12. expect { favourite.reload }
  13. .to raise_error(ActiveRecord::RecordNotFound)
  14. end
  15. end
  16. context 'when the status account is a remote activitypub account' do
  17. let(:account) { Fabricate(:account, domain: 'host.example', protocol: :activitypub) }
  18. it 'destroys the favourite and sends a notification' do
  19. subject.call(favourite.account, status)
  20. expect { favourite.reload }
  21. .to raise_error(ActiveRecord::RecordNotFound)
  22. expect(ActivityPub::DeliveryWorker)
  23. .to have_enqueued_sidekiq_job(anything, favourite.account.id, status.account.inbox_url)
  24. end
  25. end
  26. end
  27. end
  28. end