Functional test with posting an image upload

29 views
Skip to first unread message

dlanger

unread,
Apr 13, 2012, 8:03:21 AM4/13/12
to Paperclip Plugin
I am trying to write a functional test for the create and update
methods of a controller handling a model with a Paperclip attachment.
The form in the view for these two methods contains a file upload
button and I somehow have to simulate the upload of the image.

I tried various different approaches, but non of them worked.

For example:

test "should create user" do
assert_difference('User.count') do
pic = fixture_file_upload(files/sample_file.jpg)
post :create, :user => {:first_name => 'John', :last_name =>
'Doe', :photo => pic}
end
assert_redirect_to user_path
end

When running the tests, I run into the error message "NoMethodError:
undefined method 'tempfile' for #<File:/tmp/sample_file.jpg-...>".

How could I get this running?



Reply all
Reply to author
Forward
0 new messages