From 8f2c2cc85443821961012544917f310e7587d9c9 Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Wed, 14 Mar 2018 14:21:42 +0000 Subject: [PATCH] Enforce the maximum of 40 items in a collection. We're only display 40 now (was 20) so enforce this to avoid confusion. --- collections/programming-languages/index.md | 1 - test/collections_test.rb | 7 +++++++ test/collections_test_helper.rb | 1 + 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/collections/programming-languages/index.md b/collections/programming-languages/index.md index 70d06f8c..c3eca36c 100644 --- a/collections/programming-languages/index.md +++ b/collections/programming-languages/index.md @@ -40,7 +40,6 @@ items: - purescript/purescript - PowerShell/PowerShell - rakudo/rakudo - - SWI-Prolog/swipl-devel display_name: Programming languages created_by: leereilly --- diff --git a/test/collections_test.rb b/test/collections_test.rb index b9a1724d..ee3392d7 100644 --- a/test/collections_test.rb +++ b/test/collections_test.rb @@ -32,6 +32,13 @@ describe "collections" do assert_empty invalid_slugs, "Invalid item slugs #{invalid_slugs}" end + it "has valid number of items" do + items = items_for_collection(collection) + assert (1...MAX_COLLECTION_ITEMS_LENGTH + 1).cover?(items.length), + "must have no more than #{MAX_COLLECTION_ITEMS_LENGTH} items " \ + "(currently #{items.length})" + end + it "fails if a repository does not exist or is private" do errors = [] diff --git a/test/collections_test_helper.rb b/test/collections_test_helper.rb index 665d3d88..ba11c222 100644 --- a/test/collections_test_helper.rb +++ b/test/collections_test_helper.rb @@ -5,6 +5,7 @@ require_relative "./test_helper" VALID_COLLECTION_METADATA_KEYS = %w[collection created_by display_name image items].freeze REQUIRED_COLLECTION_METADATA_KEYS = %w[items display_name].freeze +MAX_COLLECTION_ITEMS_LENGTH = 40 MAX_COLLECTION_SLUG_LENGTH = 40 MAX_COLLECTION_DISPLAY_NAME_LENGTH = 100