Skip to content

Commit

Permalink
Tests: Add test to validate file upload limits (#2612)
Browse files Browse the repository at this point in the history
* Tests: Add test to validate file upload limits

* Restore original settings after test
  • Loading branch information
pglombardo authored Oct 11, 2024
1 parent 84901c2 commit 9f144af
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions test/integration/file_push/file_push_creation_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,38 @@ def test_file_push_creation
assert(download_link.first.content.include?("monkey.png"))
end

def test_file_push_creation_with_limits
@old_max_files_uploads = Settings.files.max_file_uploads
Settings.files.max_file_uploads = 1

# Upload 1 file
post file_pushes_path, params: {
file_push: {
payload: "Message",
files: [
fixture_file_upload("monkey.png", "image/jpeg")
]
}
}
assert_response :redirect
follow_redirect!
assert_response :success
assert_select "h2", "Your push has been created."

# Upload 2 files should fail
post file_pushes_path, params: {
file_push: {
payload: "Message",
files: [
fixture_file_upload("monkey.png", "image/jpeg"),
fixture_file_upload("test-file.txt", "text/plain")
]
}
}
assert_response :unprocessable_entity
Settings.files.max_file_uploads = @old_max_files_uploads
end

def test_ascii_8bit_message_creation
get new_file_push_path
assert_response :success
Expand Down

0 comments on commit 9f144af

Please sign in to comment.