Skip to content

Commit

Permalink
change max file upload count to 20
Browse files Browse the repository at this point in the history
  • Loading branch information
asmega committed Nov 20, 2023
1 parent 44b8f25 commit 50a75fb
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 24 deletions.
2 changes: 1 addition & 1 deletion app/validators/file_upload_validator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
14 changes: 3 additions & 11 deletions spec/forms/referrals/allegation_evidence/upload_form_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 2 additions & 12 deletions spec/validators/file_upload_validator_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down

0 comments on commit 50a75fb

Please sign in to comment.