You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

44 lines
1.7 KiB

  1. # frozen_string_literal: true
  2. require 'rails_helper'
  3. describe ActivityPub::NoteSerializer do
  4. let!(:account) { Fabricate(:account) }
  5. let!(:other) { Fabricate(:account) }
  6. let!(:parent) { Fabricate(:status, account: account, visibility: :public) }
  7. let!(:reply1) { Fabricate(:status, account: account, thread: parent, visibility: :public) }
  8. let!(:reply2) { Fabricate(:status, account: account, thread: parent, visibility: :public) }
  9. let!(:reply3) { Fabricate(:status, account: other, thread: parent, visibility: :public) }
  10. let!(:reply4) { Fabricate(:status, account: account, thread: parent, visibility: :public) }
  11. let!(:reply5) { Fabricate(:status, account: account, thread: parent, visibility: :direct) }
  12. before(:each) do
  13. @serialization = ActiveModelSerializers::SerializableResource.new(parent, serializer: ActivityPub::NoteSerializer, adapter: ActivityPub::Adapter)
  14. end
  15. subject { JSON.parse(@serialization.to_json) }
  16. it 'has a Note type' do
  17. expect(subject['type']).to eql('Note')
  18. end
  19. it 'has a replies collection' do
  20. expect(subject['replies']['type']).to eql('Collection')
  21. end
  22. it 'has a replies collection with a first Page' do
  23. expect(subject['replies']['first']['type']).to eql('CollectionPage')
  24. end
  25. it 'includes public self-replies in its replies collection' do
  26. expect(subject['replies']['first']['items']).to include(reply1.uri, reply2.uri, reply4.uri)
  27. end
  28. it 'does not include replies from others in its replies collection' do
  29. expect(subject['replies']['first']['items']).to_not include(reply3.uri)
  30. end
  31. it 'does not include replies with direct visibility in its replies collection' do
  32. expect(subject['replies']['first']['items']).to_not include(reply5.uri)
  33. end
  34. end