status_reach_finder_spec.rb 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. # frozen_string_literal: true
  2. require 'rails_helper'
  3. describe StatusReachFinder do
  4. describe '#inboxes' do
  5. context 'for a local status' do
  6. let(:parent_status) { nil }
  7. let(:visibility) { :public }
  8. let(:alice) { Fabricate(:account, username: 'alice') }
  9. let(:status) { Fabricate(:status, account: alice, thread: parent_status, visibility: visibility) }
  10. subject { described_class.new(status) }
  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. context do
  56. it 'includes the inbox of the replier' do
  57. expect(subject.inboxes).to include 'https://foo.bar/inbox'
  58. end
  59. end
  60. context 'when status is not public' do
  61. let(:visibility) { :private }
  62. it 'does not include the inbox of the replier' do
  63. expect(subject.inboxes).to_not include 'https://foo.bar/inbox'
  64. end
  65. end
  66. end
  67. context 'when it is a reply to a remote account' do
  68. let(:bob) { Fabricate(:account, username: 'bob', domain: 'foo.bar', protocol: :activitypub, inbox_url: 'https://foo.bar/inbox') }
  69. let(:parent_status) { Fabricate(:status, account: bob) }
  70. context do
  71. it 'includes the inbox of the replied-to account' do
  72. expect(subject.inboxes).to include 'https://foo.bar/inbox'
  73. end
  74. end
  75. context 'when status is not public and replied-to account is not mentioned' do
  76. let(:visibility) { :private }
  77. it 'does not include the inbox of the replied-to account' do
  78. expect(subject.inboxes).to_not include 'https://foo.bar/inbox'
  79. end
  80. end
  81. end
  82. end
  83. end
  84. end