1
0

status_reach_finder_spec.rb 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. # frozen_string_literal: true
  2. require 'rails_helper'
  3. RSpec.describe StatusReachFinder do
  4. describe '#inboxes' do
  5. context 'with a local status' do
  6. subject { described_class.new(status) }
  7. let(:parent_status) { nil }
  8. let(:visibility) { :public }
  9. let(:alice) { Fabricate(:account, username: 'alice') }
  10. let(:status) { Fabricate(:status, account: alice, thread: parent_status, visibility: visibility) }
  11. context 'when it contains mentions of remote accounts' do
  12. let(:bob) { Fabricate(:account, username: 'bob', domain: 'foo.bar', protocol: :activitypub, inbox_url: 'https://foo.bar/inbox') }
  13. before do
  14. status.mentions.create!(account: bob)
  15. end
  16. it 'includes the inbox of the mentioned account' do
  17. expect(subject.inboxes).to include 'https://foo.bar/inbox'
  18. end
  19. end
  20. context 'when it has been reblogged by a remote account' do
  21. let(:bob) { Fabricate(:account, username: 'bob', domain: 'foo.bar', protocol: :activitypub, inbox_url: 'https://foo.bar/inbox') }
  22. before do
  23. bob.statuses.create!(reblog: status)
  24. end
  25. it 'includes the inbox of the reblogger' do
  26. expect(subject.inboxes).to include 'https://foo.bar/inbox'
  27. end
  28. context 'when status is not public' do
  29. let(:visibility) { :private }
  30. it 'does not include the inbox of the reblogger' do
  31. expect(subject.inboxes).to_not include 'https://foo.bar/inbox'
  32. end
  33. end
  34. end
  35. context 'when it has been favourited by a remote account' do
  36. let(:bob) { Fabricate(:account, username: 'bob', domain: 'foo.bar', protocol: :activitypub, inbox_url: 'https://foo.bar/inbox') }
  37. before do
  38. bob.favourites.create!(status: status)
  39. end
  40. it 'includes the inbox of the favouriter' do
  41. expect(subject.inboxes).to include 'https://foo.bar/inbox'
  42. end
  43. context 'when status is not public' do
  44. let(:visibility) { :private }
  45. it 'does not include the inbox of the favouriter' do
  46. expect(subject.inboxes).to_not include 'https://foo.bar/inbox'
  47. end
  48. end
  49. end
  50. context 'when it has been replied to by a remote account' do
  51. let(:bob) { Fabricate(:account, username: 'bob', domain: 'foo.bar', protocol: :activitypub, inbox_url: 'https://foo.bar/inbox') }
  52. before do
  53. bob.statuses.create!(thread: status, text: 'Hoge')
  54. end
  55. it 'includes the inbox of the replier' do
  56. expect(subject.inboxes).to include 'https://foo.bar/inbox'
  57. end
  58. context 'when status is not public' do
  59. let(:visibility) { :private }
  60. it 'does not include the inbox of the replier' do
  61. expect(subject.inboxes).to_not include 'https://foo.bar/inbox'
  62. end
  63. end
  64. end
  65. context 'when it is a reply to a remote account' do
  66. let(:bob) { Fabricate(:account, username: 'bob', domain: 'foo.bar', protocol: :activitypub, inbox_url: 'https://foo.bar/inbox') }
  67. let(:parent_status) { Fabricate(:status, account: bob) }
  68. it 'includes the inbox of the replied-to account' do
  69. expect(subject.inboxes).to include 'https://foo.bar/inbox'
  70. end
  71. context 'when status is not public and replied-to account is not mentioned' do
  72. let(:visibility) { :private }
  73. it 'does not include the inbox of the replied-to account' do
  74. expect(subject.inboxes).to_not include 'https://foo.bar/inbox'
  75. end
  76. end
  77. end
  78. end
  79. end
  80. end