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