2019-10-12 21:52:04 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-06-22 15:30:34 +05:30
|
|
|
require 'spec_helper'
|
|
|
|
|
2020-06-23 00:09:42 +05:30
|
|
|
RSpec.describe 'Import/Export - project import integration test', :js do
|
2018-12-05 23:21:45 +05:30
|
|
|
include GitHelpers
|
2016-06-22 15:30:34 +05:30
|
|
|
|
2017-09-10 17:25:29 +05:30
|
|
|
let(:user) { create(:user) }
|
2016-06-22 15:30:34 +05:30
|
|
|
let(:file) { File.join(Rails.root, 'spec', 'features', 'projects', 'import_export', 'test_project_export.tar.gz') }
|
2017-08-17 22:00:37 +05:30
|
|
|
let(:export_path) { "#{Dir.tmpdir}/import_file_spec" }
|
2016-06-22 15:30:34 +05:30
|
|
|
|
2018-11-08 19:23:39 +05:30
|
|
|
before do
|
2018-11-20 20:47:30 +05:30
|
|
|
stub_uploads_object_storage(FileUploader)
|
2019-12-26 22:10:19 +05:30
|
|
|
allow_next_instance_of(Gitlab::ImportExport) do |instance|
|
|
|
|
allow(instance).to receive(:storage_path).and_return(export_path)
|
|
|
|
end
|
2017-09-10 17:25:29 +05:30
|
|
|
gitlab_sign_in(user)
|
2016-06-22 15:30:34 +05:30
|
|
|
end
|
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
after do
|
2016-06-22 15:30:34 +05:30
|
|
|
FileUtils.rm_rf(export_path, secure: true)
|
|
|
|
end
|
|
|
|
|
2016-11-03 12:29:30 +05:30
|
|
|
context 'when selecting the namespace' do
|
|
|
|
let(:user) { create(:admin) }
|
2018-03-17 18:26:18 +05:30
|
|
|
let!(:namespace) { user.namespace }
|
2018-12-05 23:21:45 +05:30
|
|
|
let(:randomHex) { SecureRandom.hex }
|
|
|
|
let(:project_name) { 'Test Project Name' + randomHex }
|
|
|
|
let(:project_path) { 'test-project-name' + randomHex }
|
2016-11-03 12:29:30 +05:30
|
|
|
|
2021-02-22 17:27:13 +05:30
|
|
|
it 'user imports an exported project successfully', :sidekiq_might_not_need_inline do
|
|
|
|
visit new_project_path
|
2021-09-04 01:27:46 +05:30
|
|
|
click_import_project
|
2021-02-22 17:27:13 +05:30
|
|
|
click_link 'GitLab export'
|
2016-06-22 15:30:34 +05:30
|
|
|
|
2021-02-22 17:27:13 +05:30
|
|
|
fill_in :name, with: 'Test Project Name', visible: true
|
|
|
|
fill_in :path, with: 'test-project-path', visible: true
|
|
|
|
attach_file('file', file)
|
2016-06-22 15:30:34 +05:30
|
|
|
|
2021-09-04 01:27:46 +05:30
|
|
|
expect { click_button 'Import project' }.to change { Project.count }.by(1)
|
2016-06-22 15:30:34 +05:30
|
|
|
|
2021-02-22 17:27:13 +05:30
|
|
|
project = Project.last
|
|
|
|
expect(project).not_to be_nil
|
|
|
|
expect(page).to have_content("Project 'test-project-path' is being imported")
|
2016-09-13 17:45:13 +05:30
|
|
|
end
|
2016-06-22 15:30:34 +05:30
|
|
|
|
2021-02-22 17:27:13 +05:30
|
|
|
it 'invalid project' do
|
|
|
|
project = create(:project, namespace: user.namespace)
|
2016-08-24 12:49:21 +05:30
|
|
|
|
2021-02-22 17:27:13 +05:30
|
|
|
visit new_project_path
|
2016-08-24 12:49:21 +05:30
|
|
|
|
2021-09-04 01:27:46 +05:30
|
|
|
click_import_project
|
2021-02-22 17:27:13 +05:30
|
|
|
click_link 'GitLab export'
|
|
|
|
fill_in :name, with: project.name, visible: true
|
|
|
|
attach_file('file', file)
|
2021-09-04 01:27:46 +05:30
|
|
|
click_button 'Import project'
|
2016-08-24 12:49:21 +05:30
|
|
|
|
2021-02-22 17:27:13 +05:30
|
|
|
page.within('.flash-container') do
|
|
|
|
expect(page).to have_content('Project could not be imported')
|
2016-09-13 17:45:13 +05:30
|
|
|
end
|
|
|
|
end
|
2017-09-10 17:25:29 +05:30
|
|
|
end
|
2016-09-13 17:45:13 +05:30
|
|
|
|
2021-09-04 01:27:46 +05:30
|
|
|
def click_import_project
|
2021-09-30 23:02:18 +05:30
|
|
|
find('[data-qa-panel-name="import_project"]').click
|
2016-11-03 12:29:30 +05:30
|
|
|
end
|
2016-06-22 15:30:34 +05:30
|
|
|
end
|