status_update_distribution_worker_spec.rb 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. require 'rails_helper'
  2. describe ActivityPub::StatusUpdateDistributionWorker do
  3. subject { described_class.new }
  4. let(:status) { Fabricate(:status, text: 'foo') }
  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. status.snapshot!
  10. status.text = 'bar'
  11. status.edited_at = Time.now.utc
  12. status.snapshot!
  13. status.save!
  14. end
  15. context 'with public status' do
  16. before do
  17. status.update(visibility: :public)
  18. end
  19. it 'delivers to followers' do
  20. expect_push_bulk_to_match(ActivityPub::DeliveryWorker, [[kind_of(String), status.account.id, 'http://example.com', anything]])
  21. subject.perform(status.id)
  22. end
  23. end
  24. context 'with private status' do
  25. before do
  26. status.update(visibility: :private)
  27. end
  28. it 'delivers to followers' do
  29. expect_push_bulk_to_match(ActivityPub::DeliveryWorker, [[kind_of(String), status.account.id, 'http://example.com', anything]])
  30. subject.perform(status.id)
  31. end
  32. end
  33. end
  34. end