Skip to content

Commit

Permalink
SM to VA.gov: updating attachment size requirements to match MHV SM A…
Browse files Browse the repository at this point in the history
…PI (#11708)

* [#MHV-40915] updating attachment size requirements to match MHV SM API
  • Loading branch information
oleksii-morgun authored Feb 3, 2023
1 parent ae2da88 commit e7c5036
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions app/models/message.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ class Message < Common::Base
per_page 10
max_per_page 100

MAX_TOTAL_FILE_SIZE_MB = 6.0
MAX_SINGLE_FILE_SIZE_MB = 3.0
MAX_TOTAL_FILE_SIZE_MB = 10.0
MAX_SINGLE_FILE_SIZE_MB = 6.0

include ActiveModel::Validations
include RedisCaching
Expand Down
14 changes: 7 additions & 7 deletions spec/models/message_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@
let(:file1) { instance_double(upload_class, original_filename: 'file1.jpg', size: 1.megabytes) }
let(:file2) { instance_double(upload_class, original_filename: 'file2.jpg', size: 2.megabytes) }
let(:file3) { instance_double(upload_class, original_filename: 'file3.jpg', size: 1.megabytes) }
let(:file4) { instance_double(upload_class, original_filename: 'file4.jpg', size: 2.megabytes) }
let(:file5) { instance_double(upload_class, original_filename: 'file5.jpg', size: 3.1.megabytes) }
let(:file4) { instance_double(upload_class, original_filename: 'file4.jpg', size: 4.megabytes) }
let(:file5) { instance_double(upload_class, original_filename: 'file5.jpg', size: 6.1.megabytes) }

it 'can validate file size with valid file sizes' do
message = build(:message, uploads: [file1, file2, file3, file4])
Expand All @@ -65,16 +65,16 @@
expect(message.errors[:uploads]).to include('has too many files (maximum is 4 files)')
end

it 'requires that upload file size not exceed 3 MB for any one file' do
it 'requires that upload file size not exceed 6 MB for any one file' do
message = build(:message, uploads: [file5])
expect(message).not_to be_valid
expect(message.errors[:base]).to include('The file5.jpg exceeds file size limit of 3.0 MB')
expect(message.errors[:base]).to include('The file5.jpg exceeds file size limit of 6.0 MB')
end

it 'require that total upload size not exceed 6 MB' do
message = build(:message, uploads: [file1, file2, file3, file4, file5])
it 'require that total upload size not exceed 10 MB' do
message = build(:message, uploads: [file2, file3, file4, file5])
expect(message).not_to be_valid
expect(message.errors[:base]).to include('Total size of uploads exceeds 6.0 MB')
expect(message.errors[:base]).to include('Total size of uploads exceeds 10.0 MB')
end
end
end
Expand Down

0 comments on commit e7c5036

Please sign in to comment.