0
0
Fork 0

Extract spec helper for verifing to/from public AP collection namespace (#28472)

This commit is contained in:
Matt Jankowski 2024-01-11 11:17:21 -05:00 committed by GitHub
parent b6e353537b
commit 185c806d69
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 31 additions and 6 deletions

View file

@ -84,7 +84,7 @@ RSpec.describe ActivityPub::RepliesController do
expect(page_json).to be_a Hash
expect(page_json[:items]).to be_an Array
expect(page_json[:items].size).to eq 1
expect(page_json[:items].all? { |item| item[:to].include?(ActivityPub::TagManager::COLLECTIONS[:public]) || item[:cc].include?(ActivityPub::TagManager::COLLECTIONS[:public]) }).to be true
expect(page_json[:items].all? { |item| targets_public_collection?(item) }).to be true
end
context 'when there are few self-replies' do
@ -117,8 +117,7 @@ RSpec.describe ActivityPub::RepliesController do
it 'only inlines items that are local and public or unlisted replies' do
inlined_replies = page_json[:items].select { |x| x.is_a?(Hash) }
public_collection = ActivityPub::TagManager::COLLECTIONS[:public]
expect(inlined_replies.all? { |item| item[:to].include?(public_collection) || item[:cc].include?(public_collection) }).to be true
expect(inlined_replies.all? { |item| targets_public_collection?(item) }).to be true
expect(inlined_replies.all? { |item| ActivityPub::TagManager.instance.local_uri?(item[:id]) }).to be true
end
@ -194,4 +193,14 @@ RSpec.describe ActivityPub::RepliesController do
end
end
end
private
def ap_public_collection
ActivityPub::TagManager::COLLECTIONS[:public]
end
def targets_public_collection?(item)
item[:to].include?(ap_public_collection) || item[:cc].include?(ap_public_collection)
end
end