From 0ac43700d8a88c08e6f8f854e8bb85838df5fc51 Mon Sep 17 00:00:00 2001 From: Matt Jankowski Date: Thu, 19 Dec 2024 07:30:09 -0500 Subject: [PATCH] Add coverage for `REST::AnnualReportEventSerializer` and two `ActivityPub::*` serializers (#33355) Co-authored-by: Claire --- .../accept_follow_serializer_spec.rb | 21 +++++++++++++++++++ .../reject_follow_serializer_spec.rb | 21 +++++++++++++++++++ .../annual_report_event_serializer_spec.rb | 18 ++++++++++++++++ 3 files changed, 60 insertions(+) create mode 100644 spec/serializers/activitypub/accept_follow_serializer_spec.rb create mode 100644 spec/serializers/activitypub/reject_follow_serializer_spec.rb create mode 100644 spec/serializers/rest/annual_report_event_serializer_spec.rb diff --git a/spec/serializers/activitypub/accept_follow_serializer_spec.rb b/spec/serializers/activitypub/accept_follow_serializer_spec.rb new file mode 100644 index 0000000000..0639e64b9d --- /dev/null +++ b/spec/serializers/activitypub/accept_follow_serializer_spec.rb @@ -0,0 +1,21 @@ +# frozen_string_literal: true + +require 'rails_helper' + +RSpec.describe ActivityPub::AcceptFollowSerializer do + subject { serialized_record_json(record, described_class, adapter: ActivityPub::Adapter) } + + describe 'serializing an object' do + let(:record) { Fabricate :follow_request } + + it 'returns expected attributes' do + expect(subject.deep_symbolize_keys) + .to include( + actor: eq(ActivityPub::TagManager.instance.uri_for(record.target_account)), + id: match("#accepts/follows/#{record.id}"), + object: include(type: 'Follow'), + type: 'Accept' + ) + end + end +end diff --git a/spec/serializers/activitypub/reject_follow_serializer_spec.rb b/spec/serializers/activitypub/reject_follow_serializer_spec.rb new file mode 100644 index 0000000000..10d8749178 --- /dev/null +++ b/spec/serializers/activitypub/reject_follow_serializer_spec.rb @@ -0,0 +1,21 @@ +# frozen_string_literal: true + +require 'rails_helper' + +RSpec.describe ActivityPub::RejectFollowSerializer do + subject { serialized_record_json(record, described_class, adapter: ActivityPub::Adapter) } + + describe 'serializing an object' do + let(:record) { Fabricate :follow_request } + + it 'returns expected attributes' do + expect(subject.deep_symbolize_keys) + .to include( + actor: eq(ActivityPub::TagManager.instance.uri_for(record.target_account)), + id: match("#rejects/follows/#{record.id}"), + object: include(type: 'Follow'), + type: 'Reject' + ) + end + end +end diff --git a/spec/serializers/rest/annual_report_event_serializer_spec.rb b/spec/serializers/rest/annual_report_event_serializer_spec.rb new file mode 100644 index 0000000000..b595bf3e36 --- /dev/null +++ b/spec/serializers/rest/annual_report_event_serializer_spec.rb @@ -0,0 +1,18 @@ +# frozen_string_literal: true + +require 'rails_helper' + +RSpec.describe REST::AnnualReportEventSerializer do + subject { serialized_record_json(record, described_class) } + + describe 'serializing an object' do + let(:record) { Fabricate.build :generated_annual_report, year: 2024 } + + it 'returns expected attributes' do + expect(subject.deep_symbolize_keys) + .to include( + year: '2024' + ) + end + end +end