Possible file upload bug in integration test

I created an integrations test that attempted to uploade a file as
follows:

def uploaded_file(path, content_type=“application/octet-stream”,
filename=nil)
filename ||= File.basename(path)
t = Tempfile.new(filename)
FileUtils.copy_file(path, t.path)
(class << t; self; end;).class_eval do
alias local_path path
define_method(:original_filename) { filename }
define_method(:content_type) { content_type }
end
return t
end

a JPEG helper

def uploaded_jpeg(path, filename=nil)
uploaded_file(path, ‘image/jpeg’, filename)
end

def test_this
file = uploaded_jpeg("/tmp/foo.jpg")

post “/images/post”, :file => file

end

When i did this, each time the post was done, the ‘file’ parameter was
stringified instead of passing in the actual file. This works fine in
the functional test equivalent.

I would post this on dev.rubyonrails.com, but that appears to be down.

–eric

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