Add support for Link objects in attachment (#36104)
Co-authored-by: Claire <claire.github-309c@sitedethib.com>
This commit is contained in:
1 parent
99d97477f8
commit
0114b389b0
8 files changed
+127
-19
No files matched your search
@@ -277,24 +277,16 @@ RSpec.describe ActivityPub::Activity::Create do
|
||||
end
|
||||
end
|
||||
|
||||
context 'with a standalone' do
|
||||
context 'with a standalone post' do
|
||||
let(:object_json) { build_object }
|
||||
|
||||
it 'creates status' do
|
||||
it 'creates a status with expected text and direct privacy' do
|
||||
expect { subject.perform }.to change(sender.statuses, :count).by(1)
|
||||
|
||||
status = sender.statuses.first
|
||||
|
||||
expect(status).to_not be_nil
|
||||
expect(status.text).to eq 'Lorem ipsum'
|
||||
end
|
||||
|
||||
it 'missing to/cc defaults to direct privacy' do
|
||||
expect { subject.perform }.to change(sender.statuses, :count).by(1)
|
||||
|
||||
status = sender.statuses.first
|
||||
|
||||
expect(status).to_not be_nil
|
||||
expect(status.visibility).to eq 'direct'
|
||||
end
|
||||
end
|
||||
@@ -333,6 +325,55 @@ RSpec.describe ActivityPub::Activity::Create do
|
||||
end
|
||||
end
|
||||
|
||||
context 'with a public status mentioning multiple links' do
|
||||
let(:object_json) do
|
||||
build_object(
|
||||
to: 'as:Public',
|
||||
content: 'This is a test <a href="https://joinmastodon.org">https://joinmastodon.org</a> <a href="https://activitypub.rocks/">https://activitypub.rocks/</a>'
|
||||
)
|
||||
end
|
||||
|
||||
it 'creates a status and schedules link fetching job for first link' do
|
||||
expect { subject.perform }
|
||||
.to change(sender.statuses, :count).by(1)
|
||||
|
||||
status = sender.statuses.first
|
||||
|
||||
expect(status).to_not be_nil
|
||||
|
||||
expect(LinkCrawlWorker).to have_enqueued_sidekiq_job(status.id, nil)
|
||||
|
||||
expect(status.visibility).to eq 'public'
|
||||
end
|
||||
end
|
||||
|
||||
context 'with a public status specifying a link attachment (FEP-8967)' do
|
||||
let(:object_json) do
|
||||
build_object(
|
||||
to: 'as:Public',
|
||||
content: 'This is a test <a href="https://joinmastodon.org">https://joinmastodon.org</a> <a href="https://activitypub.rocks/">https://activitypub.rocks/</a>',
|
||||
attachment: [
|
||||
{
|
||||
href: 'https://activitypub.rocks/',
|
||||
},
|
||||
]
|
||||
)
|
||||
end
|
||||
|
||||
it 'creates a status and schedules link fetching job for specified link' do
|
||||
expect { subject.perform }
|
||||
.to change(sender.statuses, :count).by(1)
|
||||
|
||||
status = sender.statuses.first
|
||||
|
||||
expect(status).to_not be_nil
|
||||
|
||||
expect(LinkCrawlWorker).to have_enqueued_sidekiq_job(status.id, 'https://activitypub.rocks/')
|
||||
|
||||
expect(status.visibility).to eq 'public'
|
||||
end
|
||||
end
|
||||
|
||||
context 'when public with Public' do
|
||||
let(:object_json) do
|
||||
build_object(
|
||||
|
||||
@@ -107,4 +107,23 @@ RSpec.describe ActivityPub::NoteSerializer do
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
context 'with a preview card' do
|
||||
let(:preview_card) { Fabricate(:preview_card) }
|
||||
|
||||
before do
|
||||
PreviewCardsStatus.create(status: parent, preview_card: preview_card)
|
||||
end
|
||||
|
||||
it 'has the expected shape (using FEP-8967)' do
|
||||
expect(subject).to include({
|
||||
'type' => 'Note',
|
||||
'attachment' => contain_exactly(
|
||||
a_hash_including(
|
||||
'href' => preview_card.url
|
||||
)
|
||||
),
|
||||
})
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in new issue
Block a user