-
Notifications
You must be signed in to change notification settings - Fork 73
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Handle multiple files through a single attachment
When setting up a form uploading multiple files through a single attachment, mail form was discarding all attachments and sending none, even though it could consider the form as delivered successfully. Now we will detect multiple files and add each of them individually. Note: the reason we are not checking for something like `respond_to?(:each)` and instead are doing a specific `is_a?(Array)` check, is because a single uploaded file from Rack (which we use in our tests) also responds to the `each` method (or rather, it delegates to the tempfile internal instance used for the upload). It appears that the Rails uploaded file does not do it, but for increased compatibility I decided to go with this implementation. The previous one worked because it tried both to add multiple files and handle a single file separately, so either one of them would work. This implementation makes an upfront decision about one or the other path, by performing the `is_a?` check. I don't love these types of checks, but this seemed the most straightforward way of doing it while keeping the code easier to follow. Closes #76
- Loading branch information
1 parent
761bee3
commit c9a3f93
Showing
4 changed files
with
20 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters