Extract spec helper for verifing to/from public AP collection namespace (#28472)
This commit is contained in:
parent
b6e353537b
commit
185c806d69
2 changed files with 31 additions and 6 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue