mirror of
https://github.com/mastodon/mastodon.git
synced 2026-03-21 18:05:23 -05:00
72 lines
2.0 KiB
Ruby
72 lines
2.0 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
require 'rails_helper'
|
|
|
|
RSpec.describe ActivityPub::RemoveSerializer do
|
|
describe '.serializer_for' do
|
|
subject { described_class.serializer_for(model, {}) }
|
|
|
|
context 'with a Status model' do
|
|
let(:model) { Status.new }
|
|
|
|
it { is_expected.to eq(described_class::UriSerializer) }
|
|
end
|
|
|
|
context 'with a FeaturedTag model' do
|
|
let(:model) { FeaturedTag.new }
|
|
|
|
it { is_expected.to eq(ActivityPub::HashtagSerializer) }
|
|
end
|
|
|
|
context 'with an Array' do
|
|
let(:model) { [] }
|
|
|
|
it { is_expected.to eq(ActiveModel::Serializer::CollectionSerializer) }
|
|
end
|
|
end
|
|
|
|
describe 'Serialization' do
|
|
subject { serialized_record_json(object, described_class, adapter: ActivityPub::Adapter) }
|
|
|
|
let(:tag_manager) { ActivityPub::TagManager.instance }
|
|
|
|
context 'with a status' do
|
|
let(:object) { Fabricate(:status) }
|
|
|
|
it 'serializes to the expected json' do
|
|
expect(subject).to include({
|
|
'type' => 'Remove',
|
|
'actor' => tag_manager.uri_for(object.account),
|
|
'target' => a_string_matching(%r{/featured$}),
|
|
'object' => tag_manager.uri_for(object),
|
|
})
|
|
|
|
expect(subject).to_not have_key('id')
|
|
expect(subject).to_not have_key('published')
|
|
expect(subject).to_not have_key('to')
|
|
expect(subject).to_not have_key('cc')
|
|
end
|
|
end
|
|
|
|
context 'with a featured tag' do
|
|
let(:object) { Fabricate(:featured_tag) }
|
|
|
|
it 'serializes to the expected json' do
|
|
expect(subject).to include({
|
|
'type' => 'Remove',
|
|
'actor' => tag_manager.uri_for(object.account),
|
|
'target' => a_string_matching(%r{/featured$}),
|
|
'object' => a_hash_including({
|
|
'type' => 'Hashtag',
|
|
}),
|
|
})
|
|
|
|
expect(subject).to_not have_key('id')
|
|
expect(subject).to_not have_key('published')
|
|
expect(subject).to_not have_key('to')
|
|
expect(subject).to_not have_key('cc')
|
|
end
|
|
end
|
|
end
|
|
end
|