I'm trying to test jquery-file-upload plugin with the autoUpload option enabled using capybara/cucumber. The issue appears to be related to the autoUpload options, since uploading in the test environment works when there is no autoUpload option set. I'm uploading with the attach_file capybara method. The method triggers the change event listener, but apparently not much else. It never hits the create action for the attachment, and when I try to trigger the submit event listener manually, the params[:attachment] in the create action is empty and the attachment can't be created.
The way it's set up currently is this:
- I have 3 models, a Project model, an Attachments model and an Issue model
- There are 2 forms on the index page for Issues - one form that deals with submitting a new attachment and another that deals with submitting new issues
- Whenever an Attachment create action is triggered, the jquery-file-upload fills out a hidden field via javascript with data needed to add the Attachment to the relevant issue - this is done with the fileuploadcompleted callback from jquery-file-upload
This way of uplading works whenever I try to upload a file manually, but fails in the test environment. I've tried adding a hidden submit button to the attachment form and when I press that button via capybara it triggers the create action but the params is once again empty. I'm running out of ideas about what to do, so if anybody had similar problems, I'd be grateful if they could help me out.
Here's some relevant code if that can help:
jquery-file-upload initalization and attachment form
Gems used:
Rails 3.2.12
Capybara 2.1.0
Capybara-webkit 1.0.0
Jquery-fileupload-rails 0.3.0 - also tested with 0.4.1, same results
If you need any more code or any other information, let me know, I can edit this post immediately.
Thanks!