diff options
author | Stan Hu <stanhu@gmail.com> | 2016-04-18 06:02:12 +0300 |
---|---|---|
committer | Stan Hu <stanhu@gmail.com> | 2016-04-18 06:02:12 +0300 |
commit | e9f20f5922e9c365b4af14e53881a7bafba4139c (patch) | |
tree | 0eb76bf2d2934ccf982d8bc71fd31f4103a40d67 /spec | |
parent | 1c93b33587a5e0a0596b43772ee9e709e9962368 (diff) | |
parent | 0be158a0725c254629e7e4e5de194021322e2fa9 (diff) |
Merge branch 'fix-issue-dropzone' into 'master'
Fixed issue with dropzone not working on new issuable
Closes #15295
See merge request !3760
Diffstat (limited to 'spec')
-rw-r--r-- | spec/features/issues_spec.rb | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/spec/features/issues_spec.rb b/spec/features/issues_spec.rb index 1ce0024e93c..35c8f93abc1 100644 --- a/spec/features/issues_spec.rb +++ b/spec/features/issues_spec.rb @@ -292,6 +292,23 @@ describe 'Issues', feature: true do end end + describe 'new issue' do + context 'dropzone upload file', js: true do + before do + visit new_namespace_project_issue_path(project.namespace, project) + end + + it 'should upload file when dragging into textarea' do + drop_in_dropzone test_image_file + + # Wait for the file to upload + sleep 1 + + expect(page.find_field("issue_description").value).to have_content 'banana_sample' + end + end + end + def first_issue page.all('ul.issues-list > li').first.text end @@ -299,4 +316,25 @@ describe 'Issues', feature: true do def last_issue page.all('ul.issues-list > li').last.text end + + def drop_in_dropzone(file_path) + # Generate a fake input selector + page.execute_script <<-JS + var fakeFileInput = window.$('<input/>').attr( + {id: 'fakeFileInput', type: 'file'} + ).appendTo('body'); + JS + # Attach the file to the fake input selector with Capybara + attach_file("fakeFileInput", file_path) + # Add the file to a fileList array and trigger the fake drop event + page.execute_script <<-JS + var fileList = [$('#fakeFileInput')[0].files[0]]; + var e = jQuery.Event('drop', { dataTransfer : { files : fileList } }); + $('.div-dropzone')[0].dropzone.listeners[0].events.drop(e); + JS + end + + def test_image_file + File.join(Rails.root, 'spec', 'fixtures', 'banana_sample.gif') + end end |