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.

65 lines
1.9 KiB

  1. require 'rails_helper'
  2. RSpec.describe ReblogService, type: :service do
  3. let(:alice) { Fabricate(:account, username: 'alice') }
  4. context 'creates a reblog with appropriate visibility' do
  5. let(:visibility) { :public }
  6. let(:reblog_visibility) { :public }
  7. let(:status) { Fabricate(:status, account: alice, visibility: visibility) }
  8. subject { ReblogService.new }
  9. before do
  10. subject.call(alice, status, visibility: reblog_visibility)
  11. end
  12. describe 'boosting privately' do
  13. let(:reblog_visibility) { :private }
  14. it 'reblogs privately' do
  15. expect(status.reblogs.first.visibility).to eq 'private'
  16. end
  17. end
  18. describe 'public reblogs of private toots should remain private' do
  19. let(:visibility) { :private }
  20. let(:reblog_visibility) { :public }
  21. it 'reblogs privately' do
  22. expect(status.reblogs.first.visibility).to eq 'private'
  23. end
  24. end
  25. end
  26. context 'ActivityPub' do
  27. let(:bob) { Fabricate(:account, username: 'bob', protocol: :activitypub, domain: 'example.com', inbox_url: 'http://example.com/inbox') }
  28. let(:status) { Fabricate(:status, account: bob) }
  29. subject { ReblogService.new }
  30. before do
  31. stub_request(:post, bob.inbox_url)
  32. allow(ActivityPub::DistributionWorker).to receive(:perform_async)
  33. subject.call(alice, status)
  34. end
  35. it 'creates a reblog' do
  36. expect(status.reblogs.count).to eq 1
  37. end
  38. describe 'after_create_commit :store_uri' do
  39. it 'keeps consistent reblog count' do
  40. expect(status.reblogs.count).to eq 1
  41. end
  42. end
  43. it 'distributes to followers' do
  44. expect(ActivityPub::DistributionWorker).to have_received(:perform_async)
  45. end
  46. it 'sends an announce activity to the author' do
  47. expect(a_request(:post, bob.inbox_url)).to have_been_made.once
  48. end
  49. end
  50. end