distribution_worker_spec.rb 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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. follower.follow!(status.account)
  9. end
  10. context 'with public status' do
  11. before do
  12. status.update(visibility: :public)
  13. end
  14. it 'delivers to followers' do
  15. expect_push_bulk_to_match(ActivityPub::DeliveryWorker, [[kind_of(String), status.account.id, 'http://example.com', anything]])
  16. subject.perform(status.id)
  17. end
  18. end
  19. context 'with private status' do
  20. before do
  21. status.update(visibility: :private)
  22. end
  23. it 'delivers to followers' do
  24. expect_push_bulk_to_match(ActivityPub::DeliveryWorker, [[kind_of(String), status.account.id, 'http://example.com', anything]])
  25. subject.perform(status.id)
  26. end
  27. end
  28. context 'with direct status' do
  29. let(:mentioned_account) { Fabricate(:account, protocol: :activitypub, inbox_url: 'https://foo.bar/inbox')}
  30. before do
  31. status.update(visibility: :direct)
  32. status.mentions.create!(account: mentioned_account)
  33. end
  34. it 'delivers to mentioned accounts' do
  35. expect_push_bulk_to_match(ActivityPub::DeliveryWorker, [[kind_of(String), status.account.id, 'https://foo.bar/inbox', anything]])
  36. subject.perform(status.id)
  37. end
  38. end
  39. end
  40. end