mastodon/spec/serializers/activitypub/featured_collection_serializer_spec.rb
2026-01-12 08:39:25 +00:00

49 lines
1.6 KiB
Ruby

# frozen_string_literal: true
require 'rails_helper'
RSpec.describe ActivityPub::FeaturedCollectionSerializer do
subject { serialized_record_json(collection, described_class, adapter: ActivityPub::Adapter) }
let(:collection) do
Fabricate(:collection,
name: 'Incredible people',
description: 'These are really amazing',
tag_name: '#people',
discoverable: false)
end
let!(:collection_items) { Fabricate.times(2, :collection_item, collection:) }
it 'serializes to the expected structure' do
expect(subject).to include({
'type' => 'FeaturedCollection',
'id' => ActivityPub::TagManager.instance.uri_for(collection),
'name' => 'Incredible people',
'summary' => 'These are really amazing',
'attributedTo' => ActivityPub::TagManager.instance.uri_for(collection.account),
'sensitive' => false,
'discoverable' => false,
'topic' => {
'href' => match(%r{/tags/people$}),
'type' => 'Hashtag',
'name' => '#people',
},
'totalItems' => 2,
'orderedItems' => [
{
'type' => 'FeaturedItem',
'featuredObject' => ActivityPub::TagManager.instance.uri_for(collection_items.first.account),
'featuredObjectType' => 'Person',
},
{
'type' => 'FeaturedItem',
'featuredObject' => ActivityPub::TagManager.instance.uri_for(collection_items.last.account),
'featuredObjectType' => 'Person',
},
],
'published' => match_api_datetime_format,
'updated' => match_api_datetime_format,
})
end
end