First draft of API to get a single collection (#37053)

This commit is contained in:
David Roetzel
2025-12-01 16:04:52 +01:00
committed by GitHub
parent 1f9ddb7cf6
commit 2d203ca72a
11 changed files with 152 additions and 5 deletions

View File

@@ -48,4 +48,28 @@ RSpec.describe Collection do
it { is_expected.to_not be_valid }
end
end
describe '#item_for' do
subject { Fabricate(:collection) }
let!(:items) { Fabricate.times(2, :collection_item, collection: subject) }
context 'when given no account' do
it 'returns all items' do
expect(subject.items_for).to match_array(items)
end
end
context 'when given an account' do
let(:account) { Fabricate(:account) }
before do
account.block!(items.first.account)
end
it 'does not return items blocked by this account' do
expect(subject.items_for(account)).to contain_exactly(items.last)
end
end
end
end