Revert "Add partial accounts to collections endpoint (#38919)" (#39128)

This commit is contained in:
David Roetzel authored and GitHub committed 2026-05-21 13:45:09 +00:00
1 parent e54f927149
commit e18ca373eb
8 files changed
+2 -140

No files matched your search

-12
View File
@@ -199,16 +199,4 @@ RSpec.describe Collection do
expect(subject.to_log_permalink).to eq ActivityPub::TagManager.instance.uri_for(subject)
end
end
describe '#top_items' do
let(:collection) { Fabricate(:collection) }
before do
5.times { |i| Fabricate(:collection_item, collection:, position: i + 1) }
end
it 'returns the topmost four items' do
expect(collection.top_items.map(&:position)).to contain_exactly(1, 2, 3, 4)
end
end
end
@@ -1,48 +0,0 @@
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe CollectionsPresenter do
subject { described_class.new(collections:) }
let(:collection_owner_one) { Fabricate(:account) }
let(:collection_owner_two) { Fabricate(:account) }
let(:collection_one) do
Fabricate(:collection,
account: collection_owner_one,
name: 'Exquisite follows')
end
let(:collection_two) do
Fabricate(:collection,
account: collection_owner_two,
name: 'Excellent people')
end
let(:collections) { [collection_one, collection_two] }
describe '#accounts' do
context 'when collections do not have any items' do
it 'includes only the collection owners' do
expect(subject.accounts).to contain_exactly(collection_owner_one, collection_owner_two)
end
end
context 'when collections include accounts' do
let(:accounts) { Fabricate.times(3, :account) }
before do
accounts[0..1].each { |a| Fabricate(:collection_item, collection: collection_one, account: a) }
accounts[1..2].each { |a| Fabricate(:collection_item, collection: collection_two, account: a) }
end
it 'includes collection owners and unique preview accounts' do
expect(subject.accounts).to contain_exactly(
collection_owner_one,
collection_owner_two,
accounts[0],
accounts[1],
accounts[2]
)
end
end
end
end
@@ -1,45 +0,0 @@
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe REST::CollectionsWithAccountPreviewsSerializer do
subject do
serialized_record_json(presenter, described_class, options: {
scope_name: :current_user, scope: nil
})
end
let(:collection_owner_one) { Fabricate(:account) }
let(:collection_owner_two) { Fabricate(:account) }
let(:featured_account) { Fabricate(:account) }
let(:collection_one) do
Fabricate(:collection,
account: collection_owner_one,
name: 'Exquisite follows')
end
let(:collection_two) do
Fabricate(:collection,
account: collection_owner_two,
name: 'Excellent people')
end
let(:collections) { [collection_one, collection_two] }
let(:presenter) { CollectionsPresenter.new(collections:) }
before do
Fabricate(:collection_item, collection: collection_one, account: featured_account)
end
it 'includes collections and partial accounts with the expected attributes' do
expect(subject).to include({
'collections' => [
a_hash_including({ 'name' => 'Exquisite follows' }),
a_hash_including({ 'name' => 'Excellent people' }),
],
'partial_accounts' => [
a_hash_including({ 'id' => collection_owner_one.id.to_s }),
a_hash_including({ 'id' => collection_owner_two.id.to_s }),
a_hash_including({ 'id' => featured_account.id.to_s }),
],
})
end
end