2023-02-22 00:55:31 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-08-12 22:44:41 +00:00
|
|
|
require 'rails_helper'
|
|
|
|
|
2024-09-04 05:12:25 +00:00
|
|
|
RSpec.describe ActivityPub::DistributionWorker do
|
2017-08-12 22:44:41 +00:00
|
|
|
subject { described_class.new }
|
|
|
|
|
|
|
|
let(:status) { Fabricate(:status) }
|
2023-07-20 16:23:48 +00:00
|
|
|
let(:follower) { Fabricate(:account, protocol: :activitypub, inbox_url: 'http://example.com', domain: 'example.com') }
|
2017-08-12 22:44:41 +00:00
|
|
|
|
|
|
|
describe '#perform' do
|
|
|
|
before do
|
|
|
|
follower.follow!(status.account)
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'with public status' do
|
|
|
|
before do
|
|
|
|
status.update(visibility: :public)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'delivers to followers' do
|
2024-06-19 13:46:52 +00:00
|
|
|
expect_push_bulk_to_match(ActivityPub::DeliveryWorker, [[match_json_values(type: 'Create'), status.account.id, 'http://example.com', anything]]) do
|
2023-11-07 09:46:28 +00:00
|
|
|
subject.perform(status.id)
|
|
|
|
end
|
2017-08-12 22:44:41 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'with private status' do
|
|
|
|
before do
|
|
|
|
status.update(visibility: :private)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'delivers to followers' do
|
2024-06-19 13:46:52 +00:00
|
|
|
expect_push_bulk_to_match(ActivityPub::DeliveryWorker, [[match_json_values(type: 'Create'), status.account.id, 'http://example.com', anything]]) do
|
2023-11-07 09:46:28 +00:00
|
|
|
subject.perform(status.id)
|
|
|
|
end
|
2017-08-12 22:44:41 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'with direct status' do
|
2023-07-20 16:23:48 +00:00
|
|
|
let(:mentioned_account) { Fabricate(:account, protocol: :activitypub, inbox_url: 'https://foo.bar/inbox', domain: 'foo.bar') }
|
2022-01-19 21:37:27 +00:00
|
|
|
|
2017-08-12 22:44:41 +00:00
|
|
|
before do
|
|
|
|
status.update(visibility: :direct)
|
2022-01-19 21:37:27 +00:00
|
|
|
status.mentions.create!(account: mentioned_account)
|
2017-08-12 22:44:41 +00:00
|
|
|
end
|
|
|
|
|
2022-01-19 21:37:27 +00:00
|
|
|
it 'delivers to mentioned accounts' do
|
2024-06-19 13:46:52 +00:00
|
|
|
expect_push_bulk_to_match(ActivityPub::DeliveryWorker, [[match_json_values(type: 'Create'), status.account.id, 'https://foo.bar/inbox', anything]]) do
|
2023-11-07 09:46:28 +00:00
|
|
|
subject.perform(status.id)
|
|
|
|
end
|
2017-08-12 22:44:41 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|