Reduce factory creation (48 -> 8) in AP::Note
serializer spec (#32492)
This commit is contained in:
parent
a11b599ffa
commit
b1c10969ac
@ -14,7 +14,7 @@ RSpec.describe ActivityPub::NoteSerializer do
|
|||||||
let!(:reply_by_account_third) { Fabricate(:status, account: account, thread: parent, visibility: :public) }
|
let!(:reply_by_account_third) { Fabricate(:status, account: account, thread: parent, visibility: :public) }
|
||||||
let!(:reply_by_account_visibility_direct) { Fabricate(:status, account: account, thread: parent, visibility: :direct) }
|
let!(:reply_by_account_visibility_direct) { Fabricate(:status, account: account, thread: parent, visibility: :direct) }
|
||||||
|
|
||||||
it 'has the expected shape' do
|
it 'has the expected shape and replies collection' do
|
||||||
expect(subject).to include({
|
expect(subject).to include({
|
||||||
'@context' => include('https://www.w3.org/ns/activitystreams'),
|
'@context' => include('https://www.w3.org/ns/activitystreams'),
|
||||||
'type' => 'Note',
|
'type' => 'Note',
|
||||||
@ -22,26 +22,23 @@ RSpec.describe ActivityPub::NoteSerializer do
|
|||||||
'contentMap' => include({
|
'contentMap' => include({
|
||||||
'zh-TW' => a_kind_of(String),
|
'zh-TW' => a_kind_of(String),
|
||||||
}),
|
}),
|
||||||
|
'replies' => replies_collection_values,
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'has a replies collection' do
|
def replies_collection_values
|
||||||
expect(subject['replies']['type']).to eql('Collection')
|
include(
|
||||||
|
'type' => eql('Collection'),
|
||||||
|
'first' => include(
|
||||||
|
'type' => eql('CollectionPage'),
|
||||||
|
'items' => reply_items
|
||||||
|
)
|
||||||
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'has a replies collection with a first Page' do
|
def reply_items
|
||||||
expect(subject['replies']['first']['type']).to eql('CollectionPage')
|
include(reply_by_account_first.uri, reply_by_account_next.uri, reply_by_account_third.uri) # Public self replies
|
||||||
end
|
.and(not_include(reply_by_other_first.uri)) # Replies from others
|
||||||
|
.and(not_include(reply_by_account_visibility_direct.uri)) # Replies with direct visibility
|
||||||
it 'includes public self-replies in its replies collection' do
|
|
||||||
expect(subject['replies']['first']['items']).to include(reply_by_account_first.uri, reply_by_account_next.uri, reply_by_account_third.uri)
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'does not include replies from others in its replies collection' do
|
|
||||||
expect(subject['replies']['first']['items']).to_not include(reply_by_other_first.uri)
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'does not include replies with direct visibility in its replies collection' do
|
|
||||||
expect(subject['replies']['first']['items']).to_not include(reply_by_account_visibility_direct.uri)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user