logo

mastofe

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

reblog_service_spec.rb (1666B)


  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. describe 'after_create_commit :store_uri' do
  32. it 'keeps consistent reblog count' do
  33. expect(status.reblogs.count).to eq 1
  34. end
  35. end
  36. it 'distributes to followers' do
  37. expect(ActivityPub::DistributionWorker).to have_received(:perform_async)
  38. end
  39. it 'sends an announce activity to the author' do
  40. expect(a_request(:post, bob.inbox_url)).to have_been_made.once
  41. end
  42. end
  43. end