From 56bddfbfa39956ea3a8c52721eb364b1120634f6 Mon Sep 17 00:00:00 2001 From: Matt Jankowski Date: Fri, 10 Mar 2023 06:12:51 -0500 Subject: Serializers spec coverage (#24017) --- .../activitypub/device_serializer_spec.rb | 20 ++++++++++++++++++++ .../activitypub/one_time_key_serializer_spec.rb | 20 ++++++++++++++++++++ .../activitypub/undo_like_serializer_spec.rb | 20 ++++++++++++++++++++ spec/serializers/activitypub/vote_serializer_spec.rb | 20 ++++++++++++++++++++ 4 files changed, 80 insertions(+) create mode 100644 spec/serializers/activitypub/device_serializer_spec.rb create mode 100644 spec/serializers/activitypub/one_time_key_serializer_spec.rb create mode 100644 spec/serializers/activitypub/undo_like_serializer_spec.rb create mode 100644 spec/serializers/activitypub/vote_serializer_spec.rb (limited to 'spec/serializers/activitypub') diff --git a/spec/serializers/activitypub/device_serializer_spec.rb b/spec/serializers/activitypub/device_serializer_spec.rb new file mode 100644 index 000000000..2a3be8212 --- /dev/null +++ b/spec/serializers/activitypub/device_serializer_spec.rb @@ -0,0 +1,20 @@ +# frozen_string_literal: true + +require 'rails_helper' + +describe ActivityPub::DeviceSerializer do + let(:serialization) do + JSON.parse( + ActiveModelSerializers::SerializableResource.new( + record, serializer: described_class + ).to_json + ) + end + let(:record) { Fabricate(:device) } + + describe 'type' do + it 'returns correct serialized type' do + expect(serialization['type']).to eq('Device') + end + end +end diff --git a/spec/serializers/activitypub/one_time_key_serializer_spec.rb b/spec/serializers/activitypub/one_time_key_serializer_spec.rb new file mode 100644 index 000000000..6fe1f0618 --- /dev/null +++ b/spec/serializers/activitypub/one_time_key_serializer_spec.rb @@ -0,0 +1,20 @@ +# frozen_string_literal: true + +require 'rails_helper' + +describe ActivityPub::OneTimeKeySerializer do + let(:serialization) do + JSON.parse( + ActiveModelSerializers::SerializableResource.new( + record, serializer: described_class + ).to_json + ) + end + let(:record) { Fabricate(:one_time_key) } + + describe 'type' do + it 'returns correct serialized type' do + expect(serialization['type']).to eq('Curve25519Key') + end + end +end diff --git a/spec/serializers/activitypub/undo_like_serializer_spec.rb b/spec/serializers/activitypub/undo_like_serializer_spec.rb new file mode 100644 index 000000000..43cf7192e --- /dev/null +++ b/spec/serializers/activitypub/undo_like_serializer_spec.rb @@ -0,0 +1,20 @@ +# frozen_string_literal: true + +require 'rails_helper' + +describe ActivityPub::UndoLikeSerializer do + let(:serialization) do + JSON.parse( + ActiveModelSerializers::SerializableResource.new( + record, serializer: described_class + ).to_json + ) + end + let(:record) { Fabricate(:favourite) } + + describe 'type' do + it 'returns correct serialized type' do + expect(serialization['type']).to eq('Undo') + end + end +end diff --git a/spec/serializers/activitypub/vote_serializer_spec.rb b/spec/serializers/activitypub/vote_serializer_spec.rb new file mode 100644 index 000000000..c329542d7 --- /dev/null +++ b/spec/serializers/activitypub/vote_serializer_spec.rb @@ -0,0 +1,20 @@ +# frozen_string_literal: true + +require 'rails_helper' + +describe ActivityPub::VoteSerializer do + let(:serialization) do + JSON.parse( + ActiveModelSerializers::SerializableResource.new( + record, serializer: described_class + ).to_json + ) + end + let(:record) { Fabricate(:poll_vote) } + + describe 'type' do + it 'returns correct serialized type' do + expect(serialization['type']).to eq('Create') + end + end +end -- cgit