Fix fediverse:creator metadata not showing up in REST API (#33466)

This commit is contained in:
Claire 2025-01-06 11:04:25 +01:00 committed by GitHub
parent 08dd11f8d4
commit dbbf450ef5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 19 additions and 2 deletions

View File

@ -170,7 +170,7 @@ class PreviewCard < ApplicationRecord
private private
def serialized_authors def serialized_authors
if author_name? || author_url? if author_name? || author_url? || author_account_id?
PreviewCard::Author PreviewCard::Author
.new(self) .new(self)
end end

View File

@ -21,7 +21,24 @@ RSpec.describe REST::PreviewCardSerializer do
end end
end end
context 'when preview card has author data' do context 'when preview card has fediverse author data' do
let(:preview_card) { Fabricate.build :preview_card, author_account: Fabricate(:account) }
it 'includes populated authors array' do
expect(subject.deep_symbolize_keys)
.to include(
authors: be_an(Array).and(
contain_exactly(
include(
account: be_present
)
)
)
)
end
end
context 'when preview card has non-fediverse author data' do
let(:preview_card) { Fabricate.build :preview_card, author_name: 'Name', author_url: 'https://host.example/123' } let(:preview_card) { Fabricate.build :preview_card, author_name: 'Name', author_url: 'https://host.example/123' }
it 'includes populated authors array' do it 'includes populated authors array' do