Merge remote-tracking branch 'parent/main' into upstream-20241113

This commit is contained in:
KMY 2024-11-13 08:17:38 +09:00
commit 910eafda63
177 changed files with 1625 additions and 659 deletions

View file

@ -0,0 +1,39 @@
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe ActivityPub::ActorSerializer do
subject { serialized_record_json(record, described_class) }
describe '#type' do
context 'with the instance actor' do
let(:record) { Account.find(Account::INSTANCE_ACTOR_ID) }
it { is_expected.to include('type' => 'Application') }
end
context 'with an application actor' do
let(:record) { Fabricate :account, actor_type: 'Application' }
it { is_expected.to include('type' => 'Service') }
end
context 'with a service actor' do
let(:record) { Fabricate :account, actor_type: 'Service' }
it { is_expected.to include('type' => 'Service') }
end
context 'with a Group actor' do
let(:record) { Fabricate :account, actor_type: 'Group' }
it { is_expected.to include('type' => 'Group') }
end
context 'with a Person actor' do
let(:record) { Fabricate :account, actor_type: 'Person' }
it { is_expected.to include('type' => 'Person') }
end
end
end

View file

@ -0,0 +1,27 @@
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe ActivityPub::AddSerializer 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
end

View file

@ -0,0 +1,39 @@
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe ActivityPub::CollectionSerializer 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(ActivityPub::NoteSerializer) }
end
context 'with a FeaturedTag model' do
let(:model) { FeaturedTag.new }
it { is_expected.to eq(ActivityPub::HashtagSerializer) }
end
context 'with an ActivityPub::CollectionPresenter' do
let(:model) { ActivityPub::CollectionPresenter.new }
it { is_expected.to eq(described_class) }
end
context 'with a String' do
let(:model) { '' }
it { is_expected.to eq(described_class::StringSerializer) }
end
context 'with an Array' do
let(:model) { [] }
it { is_expected.to eq(ActiveModel::Serializer::CollectionSerializer) }
end
end
end

View file

@ -0,0 +1,27 @@
# 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
end