Topic: fucntional test of image uploading controller

Hi,
in my app, I allow users to upload pictures.  I wonder how I can post a image to my picture upload controller in my functional test.

here's the rhtml code for uploading a picture:

    <%= form_tag({:action => 'create'}, {:multipart => true})%>
        <%= file_field 'image', 'data' %>
        <%= submit_tag 'Upload' %>
    <%= end_form_tag %>

here's how I save the picture:
@image = ProductImage.create(:data => params[:image][:data], :date => Date.today(), 
            :user_id => self.current_user.id, :default_image => (images.length == 0))

Thanks.
yaxm

Re: fucntional test of image uploading controller

I would start attacking the problem by 'p params' in my controller.  From there, you should be able to see what the parameters look like, generate a 1x1 pixel image, base64 encode it, and go for it.

BrewControl.com - Brewery and Brewpub management powered by RoR

Re: fucntional test of image uploading controller

here's the documentation on how to test file upload:
http://manuals.rubyonrails.com/read/chapter/28#page237