Forum: Ruby on Rails Testing for multipart form uploads

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
helzer (Guest)
on 2007-04-25 10:18
(Received via mailing list)

I'm trying to do integration tests that require uploading files via
multipart posts.

Have seen a very similar discussion, but cannot get it to work. Maybe,
it's out of date now with Rails 1.2.3:

>From what I understand, fixture_file_upload's output is translated a
String. There's a ticket discussing this here:
The solution there is to use code that does the multipart encoding:

Again, it doesn't work. The file I'm getting is a truncated version of
the original.

This is my code:

  fdata = fixture_file_upload(fname,'application/octet-stream')
url_for(:controller=>:support_files, :action=>:create),

BTW: On the other side, I'm using acts_as_attachment to process the
multipart data. It works fine when I'm using a browser to upload.

Any recommendations on how to get this to work in an integration
testing environment?

helzer (Guest)
on 2007-05-23 18:25
(Received via mailing list)
A quick update, if anyone's interested:

The solution, shown in the ticket below, actually works fine AFTER I
fixed the file read to open in mode 'rb' and not 'r'.

This topic is locked and can not be replied to.