reblog_service_spec.rb 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. require 'rails_helper'
  2. RSpec.describe ReblogService do
  3. let(:alice) { Fabricate(:account, username: 'alice') }
  4. context 'OStatus' do
  5. let(:bob) { Fabricate(:account, username: 'bob', domain: 'example.com', salmon_url: 'http://salmon.example.com') }
  6. let(:status) { Fabricate(:status, account: bob, uri: 'tag:example.com;something:something') }
  7. subject { ReblogService.new }
  8. before do
  9. stub_request(:post, 'http://salmon.example.com')
  10. subject.call(alice, status)
  11. end
  12. it 'creates a reblog' do
  13. expect(status.reblogs.count).to eq 1
  14. end
  15. it 'sends a Salmon slap for a remote reblog' do
  16. expect(a_request(:post, 'http://salmon.example.com')).to have_been_made
  17. end
  18. end
  19. context 'ActivityPub' do
  20. let(:bob) { Fabricate(:account, username: 'bob', protocol: :activitypub, domain: 'example.com', inbox_url: 'http://example.com/inbox') }
  21. let(:status) { Fabricate(:status, account: bob) }
  22. subject { ReblogService.new }
  23. before do
  24. stub_request(:post, bob.inbox_url)
  25. allow(ActivityPub::DistributionWorker).to receive(:perform_async)
  26. subject.call(alice, status)
  27. end
  28. it 'creates a reblog' do
  29. expect(status.reblogs.count).to eq 1
  30. end
  31. it 'distributes to followers' do
  32. expect(ActivityPub::DistributionWorker).to have_received(:perform_async)
  33. end
  34. it 'sends an announce activity to the author' do
  35. expect(a_request(:post, bob.inbox_url)).to have_been_made.once
  36. end
  37. end
  38. end