From 50a75fb164cfa71c18738fc15f2ae9dd05321220 Mon Sep 17 00:00:00 2001 From: Phil Lee Date: Mon, 20 Nov 2023 11:45:50 +0000 Subject: [PATCH] change max file upload count to 20 --- app/validators/file_upload_validator.rb | 2 +- .../allegation_evidence/upload_form_spec.rb | 14 +++----------- spec/validators/file_upload_validator_spec.rb | 14 ++------------ 3 files changed, 6 insertions(+), 24 deletions(-) diff --git a/app/validators/file_upload_validator.rb b/app/validators/file_upload_validator.rb index 82b54da0e..ed638e191 100644 --- a/app/validators/file_upload_validator.rb +++ b/app/validators/file_upload_validator.rb @@ -2,7 +2,7 @@ class FileUploadValidator < ActiveModel::EachValidator include FileSizeHelper MAX_FILE_SIZE = 50.megabytes - MAX_FILES = 10 + MAX_FILES = 20 CONTENT_TYPES = { ".apng" => "image/apng", diff --git a/spec/forms/referrals/allegation_evidence/upload_form_spec.rb b/spec/forms/referrals/allegation_evidence/upload_form_spec.rb index 6ad67ecc6..cecd79ff3 100644 --- a/spec/forms/referrals/allegation_evidence/upload_form_spec.rb +++ b/spec/forms/referrals/allegation_evidence/upload_form_spec.rb @@ -67,19 +67,11 @@ end it "validates that the maximum number of files is not exceeded" do - upload_form.evidence_uploads = [ - fixture_file_upload("upload.txt"), - fixture_file_upload("upload.txt"), - fixture_file_upload("upload.txt"), - fixture_file_upload("upload.txt"), - fixture_file_upload("upload.txt"), - fixture_file_upload("upload.txt"), - fixture_file_upload("upload.txt"), - fixture_file_upload("upload.txt"), + upload_form.evidence_uploads = (described_class::MAX_FILES - 1).times.map do fixture_file_upload("upload.txt") - ] + end expect(upload_form.save).to be false - expect(upload_form.errors[:evidence_uploads]).to eq(["You can only upload 10 files"]) + expect(upload_form.errors[:evidence_uploads]).to eq(["You can only upload 20 files"]) end end end diff --git a/spec/validators/file_upload_validator_spec.rb b/spec/validators/file_upload_validator_spec.rb index 978c76d93..a3c0d7415 100644 --- a/spec/validators/file_upload_validator_spec.rb +++ b/spec/validators/file_upload_validator_spec.rb @@ -42,19 +42,9 @@ context "with too many files" do let(:files) do - [ - fixture_file_upload("upload1.pdf", "application/pdf"), - fixture_file_upload("upload1.pdf", "application/pdf"), - fixture_file_upload("upload1.pdf", "application/pdf"), - fixture_file_upload("upload1.pdf", "application/pdf"), - fixture_file_upload("upload1.pdf", "application/pdf"), - fixture_file_upload("upload1.pdf", "application/pdf"), - fixture_file_upload("upload1.pdf", "application/pdf"), - fixture_file_upload("upload1.pdf", "application/pdf"), - fixture_file_upload("upload1.pdf", "application/pdf"), - fixture_file_upload("upload1.pdf", "application/pdf"), + (described_class::MAX_FILES + 1).times.map do fixture_file_upload("upload1.pdf", "application/pdf") - ] + end end it { is_expected.to be_invalid }