logo

mastofe

My custom branche(s) on git.pleroma.social/pleroma/mastofe git clone https://hacktivis.me/git/mastofe.git

distribution_worker_spec.rb (1264B)


  1. require 'rails_helper'
  2. describe ActivityPub::DistributionWorker do
  3. subject { described_class.new }
  4. let(:status) { Fabricate(:status) }
  5. let(:follower) { Fabricate(:account, protocol: :activitypub, inbox_url: 'http://example.com') }
  6. describe '#perform' do
  7. before do
  8. allow(ActivityPub::DeliveryWorker).to receive(:push_bulk)
  9. follower.follow!(status.account)
  10. end
  11. context 'with public status' do
  12. before do
  13. status.update(visibility: :public)
  14. end
  15. it 'delivers to followers' do
  16. subject.perform(status.id)
  17. expect(ActivityPub::DeliveryWorker).to have_received(:push_bulk).with(['http://example.com'])
  18. end
  19. end
  20. context 'with private status' do
  21. before do
  22. status.update(visibility: :private)
  23. end
  24. it 'delivers to followers' do
  25. subject.perform(status.id)
  26. expect(ActivityPub::DeliveryWorker).to have_received(:push_bulk).with(['http://example.com'])
  27. end
  28. end
  29. context 'with direct status' do
  30. before do
  31. status.update(visibility: :direct)
  32. end
  33. it 'does nothing' do
  34. subject.perform(status.id)
  35. expect(ActivityPub::DeliveryWorker).to_not have_received(:push_bulk)
  36. end
  37. end
  38. end
  39. end