Start of handling FeatureRequest activities (#38193)
This commit is contained in:
1 parent
8d5d66ecfc
commit
c993daa347
5 files changed
+115
-2
No files matched your search
@@ -0,0 +1,54 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe ActivityPub::Activity::FeatureRequest do
|
||||
let(:sender) { Fabricate(:remote_account) }
|
||||
let(:recipient) { Fabricate(:account, discoverable:) }
|
||||
let(:collection) { Fabricate(:remote_collection, account: sender) }
|
||||
|
||||
let(:json) do
|
||||
{
|
||||
'@context' => [
|
||||
'https://www.w3.org/ns/activitystreams',
|
||||
],
|
||||
'id' => 'https://example.com/feature_requests/1',
|
||||
'type' => 'FeatureRequest',
|
||||
'actor' => sender.uri,
|
||||
'object' => ActivityPub::TagManager.instance.uri_for(recipient),
|
||||
'instrument' => collection.uri,
|
||||
}
|
||||
end
|
||||
|
||||
describe '#perform', feature: :collections_federation do
|
||||
subject { described_class.new(json, sender) }
|
||||
|
||||
context 'when recipient is discoverable' do
|
||||
let(:discoverable) { true }
|
||||
|
||||
it 'schedules a job to send an `Accept` activity' do
|
||||
expect { subject.perform }
|
||||
.to enqueue_sidekiq_job(ActivityPub::DeliveryWorker)
|
||||
.with(satisfying do |body|
|
||||
response_json = JSON.parse(body)
|
||||
response_json['type'] == 'Accept' &&
|
||||
response_json['to'] == sender.uri
|
||||
end, recipient.id, sender.inbox_url)
|
||||
end
|
||||
end
|
||||
|
||||
context 'when recipient is not discoverable' do
|
||||
let(:discoverable) { false }
|
||||
|
||||
it 'schedules a job to send a `Reject` activity' do
|
||||
expect { subject.perform }
|
||||
.to enqueue_sidekiq_job(ActivityPub::DeliveryWorker)
|
||||
.with(satisfying do |body|
|
||||
response_json = JSON.parse(body)
|
||||
response_json['type'] == 'Reject' &&
|
||||
response_json['to'] == sender.uri
|
||||
end, recipient.id, sender.inbox_url)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -17,8 +17,9 @@ RSpec.describe CollectionItem do
|
||||
end
|
||||
|
||||
context 'when item is not local' do
|
||||
subject { Fabricate.build(:collection_item, collection: remote_collection) }
|
||||
subject { Fabricate.build(:collection_item, collection: remote_collection, account:) }
|
||||
|
||||
let(:account) { Fabricate.build(:remote_account) }
|
||||
let(:remote_collection) { Fabricate.build(:collection, local: false) }
|
||||
|
||||
it { is_expected.to validate_presence_of(:uri) }
|
||||
@@ -28,6 +29,12 @@ RSpec.describe CollectionItem do
|
||||
|
||||
it { is_expected.to validate_presence_of(:approval_uri) }
|
||||
end
|
||||
|
||||
context 'when account is local' do
|
||||
let(:account) { Fabricate.build(:account) }
|
||||
|
||||
it { is_expected.to_not validate_presence_of(:uri) }
|
||||
end
|
||||
end
|
||||
|
||||
context 'when account is not present' do
|
||||
|
||||
Reference in new issue
Block a user