Testing for multipart form uploads


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?


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 forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs