dlanger
unread,Apr 13, 2012, 8:03:21 AM4/13/12Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
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?