From 19614ba2477f3d12468f5ec251ce1cc5f8c6210c Mon Sep 17 00:00:00 2001 From: Nick Schonning Date: Thu, 23 Feb 2023 17:17:48 -0500 Subject: Rename ActivityPub Serializer Specs (#23844) --- .../activitypub/note_serializer_spec.rb | 44 ++++++++++++++++++++++ spec/serializers/activitypub/note_spec.rb | 44 ---------------------- .../activitypub/update_poll_serializer_spec.rb | 27 +++++++++++++ spec/serializers/activitypub/update_poll_spec.rb | 27 ------------- 4 files changed, 71 insertions(+), 71 deletions(-) create mode 100644 spec/serializers/activitypub/note_serializer_spec.rb delete mode 100644 spec/serializers/activitypub/note_spec.rb create mode 100644 spec/serializers/activitypub/update_poll_serializer_spec.rb delete mode 100644 spec/serializers/activitypub/update_poll_spec.rb (limited to 'spec/serializers') diff --git a/spec/serializers/activitypub/note_serializer_spec.rb b/spec/serializers/activitypub/note_serializer_spec.rb new file mode 100644 index 000000000..7ea47baef --- /dev/null +++ b/spec/serializers/activitypub/note_serializer_spec.rb @@ -0,0 +1,44 @@ +# frozen_string_literal: true + +require 'rails_helper' + +describe ActivityPub::NoteSerializer do + subject { JSON.parse(@serialization.to_json) } + + let!(:account) { Fabricate(:account) } + let!(:other) { Fabricate(:account) } + let!(:parent) { Fabricate(:status, account: account, visibility: :public) } + let!(:reply1) { Fabricate(:status, account: account, thread: parent, visibility: :public) } + let!(:reply2) { Fabricate(:status, account: account, thread: parent, visibility: :public) } + let!(:reply3) { Fabricate(:status, account: other, thread: parent, visibility: :public) } + let!(:reply4) { Fabricate(:status, account: account, thread: parent, visibility: :public) } + let!(:reply5) { Fabricate(:status, account: account, thread: parent, visibility: :direct) } + + before(:each) do + @serialization = ActiveModelSerializers::SerializableResource.new(parent, serializer: ActivityPub::NoteSerializer, adapter: ActivityPub::Adapter) + end + + it 'has a Note type' do + expect(subject['type']).to eql('Note') + end + + it 'has a replies collection' do + expect(subject['replies']['type']).to eql('Collection') + end + + it 'has a replies collection with a first Page' do + expect(subject['replies']['first']['type']).to eql('CollectionPage') + end + + it 'includes public self-replies in its replies collection' do + expect(subject['replies']['first']['items']).to include(reply1.uri, reply2.uri, reply4.uri) + end + + it 'does not include replies from others in its replies collection' do + expect(subject['replies']['first']['items']).to_not include(reply3.uri) + end + + it 'does not include replies with direct visibility in its replies collection' do + expect(subject['replies']['first']['items']).to_not include(reply5.uri) + end +end diff --git a/spec/serializers/activitypub/note_spec.rb b/spec/serializers/activitypub/note_spec.rb deleted file mode 100644 index 7ea47baef..000000000 --- a/spec/serializers/activitypub/note_spec.rb +++ /dev/null @@ -1,44 +0,0 @@ -# frozen_string_literal: true - -require 'rails_helper' - -describe ActivityPub::NoteSerializer do - subject { JSON.parse(@serialization.to_json) } - - let!(:account) { Fabricate(:account) } - let!(:other) { Fabricate(:account) } - let!(:parent) { Fabricate(:status, account: account, visibility: :public) } - let!(:reply1) { Fabricate(:status, account: account, thread: parent, visibility: :public) } - let!(:reply2) { Fabricate(:status, account: account, thread: parent, visibility: :public) } - let!(:reply3) { Fabricate(:status, account: other, thread: parent, visibility: :public) } - let!(:reply4) { Fabricate(:status, account: account, thread: parent, visibility: :public) } - let!(:reply5) { Fabricate(:status, account: account, thread: parent, visibility: :direct) } - - before(:each) do - @serialization = ActiveModelSerializers::SerializableResource.new(parent, serializer: ActivityPub::NoteSerializer, adapter: ActivityPub::Adapter) - end - - it 'has a Note type' do - expect(subject['type']).to eql('Note') - end - - it 'has a replies collection' do - expect(subject['replies']['type']).to eql('Collection') - end - - it 'has a replies collection with a first Page' do - expect(subject['replies']['first']['type']).to eql('CollectionPage') - end - - it 'includes public self-replies in its replies collection' do - expect(subject['replies']['first']['items']).to include(reply1.uri, reply2.uri, reply4.uri) - end - - it 'does not include replies from others in its replies collection' do - expect(subject['replies']['first']['items']).to_not include(reply3.uri) - end - - it 'does not include replies with direct visibility in its replies collection' do - expect(subject['replies']['first']['items']).to_not include(reply5.uri) - end -end diff --git a/spec/serializers/activitypub/update_poll_serializer_spec.rb b/spec/serializers/activitypub/update_poll_serializer_spec.rb new file mode 100644 index 000000000..4360808b5 --- /dev/null +++ b/spec/serializers/activitypub/update_poll_serializer_spec.rb @@ -0,0 +1,27 @@ +# frozen_string_literal: true + +require 'rails_helper' + +describe ActivityPub::UpdatePollSerializer do + subject { JSON.parse(@serialization.to_json) } + + let(:account) { Fabricate(:account) } + let(:poll) { Fabricate(:poll, account: account) } + let!(:status) { Fabricate(:status, account: account, poll: poll) } + + before(:each) do + @serialization = ActiveModelSerializers::SerializableResource.new(status, serializer: ActivityPub::UpdatePollSerializer, adapter: ActivityPub::Adapter) + end + + it 'has a Update type' do + expect(subject['type']).to eql('Update') + end + + it 'has an object with Question type' do + expect(subject['object']['type']).to eql('Question') + end + + it 'has the correct actor URI set' do + expect(subject['actor']).to eql(ActivityPub::TagManager.instance.uri_for(account)) + end +end diff --git a/spec/serializers/activitypub/update_poll_spec.rb b/spec/serializers/activitypub/update_poll_spec.rb deleted file mode 100644 index 4360808b5..000000000 --- a/spec/serializers/activitypub/update_poll_spec.rb +++ /dev/null @@ -1,27 +0,0 @@ -# frozen_string_literal: true - -require 'rails_helper' - -describe ActivityPub::UpdatePollSerializer do - subject { JSON.parse(@serialization.to_json) } - - let(:account) { Fabricate(:account) } - let(:poll) { Fabricate(:poll, account: account) } - let!(:status) { Fabricate(:status, account: account, poll: poll) } - - before(:each) do - @serialization = ActiveModelSerializers::SerializableResource.new(status, serializer: ActivityPub::UpdatePollSerializer, adapter: ActivityPub::Adapter) - end - - it 'has a Update type' do - expect(subject['type']).to eql('Update') - end - - it 'has an object with Question type' do - expect(subject['object']['type']).to eql('Question') - end - - it 'has the correct actor URI set' do - expect(subject['actor']).to eql(ActivityPub::TagManager.instance.uri_for(account)) - end -end -- cgit