Testing for multipart form uploads

helzer
Tue, 24 Apr 2007 15:25:39 -0000

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


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---