Skip to content

Instantly share code, notes, and snippets.

@elrayle
Last active November 9, 2015 21:03
Show Gist options
  • Save elrayle/cfa15bb3be8fb726317c to your computer and use it in GitHub Desktop.
Save elrayle/cfa15bb3be8fb726317c to your computer and use it in GitHub Desktop.
describe 'upload files to collection', :js do
it "preselects the collection we are uploading files to" do
attach_file('files[]', File.dirname(__FILE__) + '/../../spec/fixtures/image.jp2')
attach_file('files[]', File.dirname(__FILE__) + '/../../spec/fixtures/jp2_fits.xml')
expect(page).to have_css('button#main_upload_start[disabled]')
first(:checkbox, 'terms_of_service').click
expect(page).to have_css('button#main_upload_start')
click_button 'main_upload_start'
expect(page).to have_css('button#main_upload_start') # passes and shouldn't - means it is still on the upload page
expect(page).to have_css('button#upload_submit') # fails and shouldn't - means it didn't go to the metadata entry page
fill_in('generic_file[tag][]', with: 'Test')
click_button 'upload_submit'
updated_collection = Collection.find(collection1.id)
expect(updated_collection.member_ids).to eq ['test_1','test_2','test_3']
end
end
@elrayle
Copy link
Author

elrayle commented Nov 9, 2015

Interactively, you will stay on the upload page when you click 'main_upload_button' (aka Start Upload) if no files are selected.

I confirmed that both attach_file statements work be testing...

  • set one in filesXXX[] instead of files[] --> fails because filesXXX[] does not exist on the page
  • set path_to_file to non-existent file --> fails because file didn't exist

This confirms that files[] is a valid field and that the two files are valid.

What I am not sure of is whether the files need to be set elsewhere in addition to files[] or some other indicator to be set for Start upload to execute properly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment