I've pasted up the code at:

http://pastie.caboo.se/126925

Since there are quite a few files involved.

Thanks for your time,

Daniel

On 11 Dec 2007, at 13:28 11 Dec 2007, David Chelimsky wrote:

On Dec 11, 2007 6:18 AM, Daniel Tenner <[EMAIL PROTECTED]> wrote:
Hi all,

I'm trying to run a Story Runner integration test that uploads a file
through Attachment-fu.

I've tried various ways of specifying the file data, from custom mocks:
class MockFile < Struct.new
(:original_filename, :read, :content_type); end
fdata = MockFile.new  "test_upload.txt", "Test Upload", "text/plain"

to 'proper' railsy stubs like:

fdata = ActionController::TestUploadedFile.new("../spec/fixtures/
test_upload.txt", "text/plain")

The actual params are specified as:
{ :uploaded_data => fdata,
     :filename => file_reference_name(identifier)
   }

Now, this is being passed successfully into attachment-fu, where it
is processed. Well, almost successfully. Somehow, along the way, the
TestUploadedFile, struct, mock, whatever you want, gets turned into a
String. Then it blows up when attachment-fu tries to retrieve the
content type:

#<NoMethodError: undefined method `content_type' for
"#<ActionController::TestUploadedFile:0x34349ac>":String>

Somehow, I can't seem to pass anything but a String down into the
controller. Even in the action, the TestUploadedFile is already
transmogrified into a String (which, of course, has no content_type
property). I put a logging statement in the ActionController too, and
it seems that the entire params hash is turned into a string
somewhere in there - which would explain why the object has literally
no chance of going through.

I'm a bit stumped by this. I guess it makes sense that params are
turned into strings - but then what sort of string should i specify
for a file upload?

Thanks for any help.

Code please.
_______________________________________________
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users

_______________________________________________
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users

Reply via email to