Testing for multipart form uploads

Hi,

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: http://groups.google.ca/group/rubyonrails-talk/browse_thread/thread/fdfd2c040a2425f4

From what I understand, fixture_file_upload's output is translated a

String. There's a ticket discussing this here: http://dev.rubyonrails.org/ticket/4635 The solution there is to use code that does the multipart encoding: integration_test_file_upload.rb

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')   multipart_post url_for(:controller=>:support_files, :action=>:create),     :session=>session,                 :project_id=>project_id,                 :support_file=>{'uploaded_data'=>fdata},                 :format=>'xml'

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?

Thanks, Helzer

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'. http://groups.google.ca/group/rubyonrails-talk/browse_thread/thread/fdfd2c040a2425f4

Amir