diff --git a/spec/features/projects/import_export/import_file_spec.rb b/spec/features/projects/import_export/import_file_spec.rb index 0bc2b85edb1737bc656a106b3f6489a7790f44dd..05f6e289841d295f87f63d0cab570576d7daa58b 100644 --- a/spec/features/projects/import_export/import_file_spec.rb +++ b/spec/features/projects/import_export/import_file_spec.rb @@ -6,14 +6,19 @@ feature 'project import', feature: true, js: true do let(:user) { create(:admin) } let!(:namespace) { create(:namespace, name: "asd", owner: user) } let(:file) { File.join(Rails.root, 'spec', 'features', 'projects', 'import_export', 'test_project_export.tar.gz') } - + let(:export_path) { "#{Dir::tmpdir}/import_file_spec" } background do - export_path = "#{Dir::tmpdir}/import_file_spec" allow_any_instance_of(Gitlab::ImportExport).to receive(:storage_path).and_return(export_path) login_as(user) end + after(:each) do + FileUtils.rm_rf(export_path, secure: true) + end + scenario 'user imports an exported project successfully' do + expect(Project.all.count).to be_zero + visit new_project_path select2('2', from: '#project_namespace_id') @@ -22,29 +27,13 @@ feature 'project import', feature: true, js: true do expect(page).to have_content('GitLab export file') expect(URI.parse(current_url).query).to eq('namespace_id=2&path=test-project-path') - attach_file('file', file) - - #TODO check timings - sleep 1 + attach_file('file', file) - click_on 'Continue to the next step' - end + click_on 'Continue to the next step' # import starts - 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 + expect(Project.last).not_to be_nil + expect(Project.last.issues).not_to be_empty + expect(Project.last.repo_exists?).to be true end end