Improve enforcement of collection item limit (#39969)
This commit is contained in:
1 parent
467c933459
commit
f8337b04fe
4 files changed
+35
-13
No files matched your search
@@ -51,20 +51,28 @@ RSpec.describe Collection do
|
||||
end
|
||||
|
||||
context 'when there are more items than allowed' do
|
||||
subject { Fabricate.build(:collection, collection_items:) }
|
||||
|
||||
let(:collection_items) { Fabricate.build_times(described_class::MAX_ITEMS + 1, :collection_item, collection: nil) }
|
||||
|
||||
it { is_expected.to_not be_valid }
|
||||
context 'when collection is local' do
|
||||
subject { Fabricate.build(:collection, collection_items:) }
|
||||
|
||||
context 'when the limit is only exceeded due to `rejected` and `revoked` items' do
|
||||
let(:collection_items) do
|
||||
items = Fabricate.build_times(described_class::MAX_ITEMS - 2, :collection_item, collection: nil, state: :accepted)
|
||||
items << Fabricate.build(:collection_item, collection: nil, state: :pending)
|
||||
items << Fabricate.build(:collection_item, collection: nil, state: :rejected)
|
||||
items << Fabricate.build(:collection_item, collection: nil, state: :revoked)
|
||||
items
|
||||
it { is_expected.to_not be_valid }
|
||||
|
||||
context 'when the limit is only exceeded due to `rejected` and `revoked` items' do
|
||||
let(:collection_items) do
|
||||
items = Fabricate.build_times(described_class::MAX_ITEMS - 2, :collection_item, collection: nil, state: :accepted)
|
||||
items << Fabricate.build(:collection_item, collection: nil, state: :pending)
|
||||
items << Fabricate.build(:collection_item, collection: nil, state: :rejected)
|
||||
items << Fabricate.build(:collection_item, collection: nil, state: :revoked)
|
||||
items
|
||||
end
|
||||
|
||||
it { is_expected.to be_valid }
|
||||
end
|
||||
end
|
||||
|
||||
context 'when collection is remote' do
|
||||
subject { Fabricate.build(:remote_collection, collection_items:) }
|
||||
|
||||
it { is_expected.to be_valid }
|
||||
end
|
||||
|
||||
Reference in new issue
Block a user