You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

46 lines
1.8 KiB

  1. require 'rails_helper'
  2. describe Pubsubhubbub::DistributionWorker do
  3. subject { Pubsubhubbub::DistributionWorker.new }
  4. let!(:alice) { Fabricate(:account, username: 'alice') }
  5. let!(:bob) { Fabricate(:account, username: 'bob', domain: 'example2.com') }
  6. let!(:anonymous_subscription) { Fabricate(:subscription, account: alice, callback_url: 'http://example1.com', confirmed: true, lease_seconds: 3600) }
  7. let!(:subscription_with_follower) { Fabricate(:subscription, account: alice, callback_url: 'http://example2.com', confirmed: true, lease_seconds: 3600) }
  8. before do
  9. bob.follow!(alice)
  10. end
  11. describe 'with public status' do
  12. let(:status) { Fabricate(:status, account: alice, text: 'Hello', visibility: :public) }
  13. it 'delivers payload to all subscriptions' do
  14. allow(Pubsubhubbub::DeliveryWorker).to receive(:push_bulk)
  15. subject.perform(status.stream_entry.id)
  16. expect(Pubsubhubbub::DeliveryWorker).to have_received(:push_bulk).with([anonymous_subscription.id, subscription_with_follower.id])
  17. end
  18. end
  19. context 'when OStatus privacy is not used' do
  20. describe 'with private status' do
  21. let(:status) { Fabricate(:status, account: alice, text: 'Hello', visibility: :private) }
  22. it 'does not deliver anything' do
  23. allow(Pubsubhubbub::DeliveryWorker).to receive(:push_bulk)
  24. subject.perform(status.stream_entry.id)
  25. expect(Pubsubhubbub::DeliveryWorker).to_not have_received(:push_bulk)
  26. end
  27. end
  28. describe 'with direct status' do
  29. let(:status) { Fabricate(:status, account: alice, text: 'Hello', visibility: :direct) }
  30. it 'does not deliver payload' do
  31. allow(Pubsubhubbub::DeliveryWorker).to receive(:push_bulk)
  32. subject.perform(status.stream_entry.id)
  33. expect(Pubsubhubbub::DeliveryWorker).to_not have_received(:push_bulk)
  34. end
  35. end
  36. end
  37. end