Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames Lopez <james@jameslopez.es>2018-07-26 13:55:21 +0300
committerJames Lopez <james@jameslopez.es>2018-08-02 12:50:19 +0300
commit07009a1f4893652e152794ae8160a2f46e00772c (patch)
treea9c03b82c4b28dfa3150cbd4735c07483b9547fb /spec/features
parent3cc420b8094ec0240b473205fc886bd9c728cc5d (diff)
Add Object Storage to GitLab project import
- Refactor uploads manager - Refactor importer, update import spec - Add more object storage specs
Diffstat (limited to 'spec/features')
-rw-r--r--spec/features/projects/import_export/import_file_object_storage_spec.rb103
-rw-r--r--spec/features/projects/import_export/import_file_spec.rb1
2 files changed, 104 insertions, 0 deletions
diff --git a/spec/features/projects/import_export/import_file_object_storage_spec.rb b/spec/features/projects/import_export/import_file_object_storage_spec.rb
new file mode 100644
index 00000000000..0d364543916
--- /dev/null
+++ b/spec/features/projects/import_export/import_file_object_storage_spec.rb
@@ -0,0 +1,103 @@
+require 'spec_helper'
+
+describe 'Import/Export - project import integration test', :js do
+ include Select2Helper
+
+ let(:user) { create(: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" }
+
+ before do
+ stub_feature_flags(import_export_object_storage: true)
+ stub_uploads_object_storage(FileUploader)
+ allow_any_instance_of(Gitlab::ImportExport).to receive(:storage_path).and_return(export_path)
+ gitlab_sign_in(user)
+ end
+
+ after do
+ FileUtils.rm_rf(export_path, secure: true)
+ end
+
+ context 'when selecting the namespace' do
+ let(:user) { create(:admin) }
+ let!(:namespace) { user.namespace }
+ let(:project_path) { 'test-project-path' + SecureRandom.hex }
+
+ context 'prefilled the path' do
+ it 'user imports an exported project successfully' do
+ visit new_project_path
+
+ select2(namespace.id, from: '#project_namespace_id')
+ fill_in :project_path, with: project_path, visible: true
+ click_import_project_tab
+ click_link 'GitLab export'
+
+ expect(page).to have_content('Import an exported GitLab project')
+ expect(URI.parse(current_url).query).to eq("namespace_id=#{namespace.id}&path=#{project_path}")
+
+ attach_file('file', file)
+ click_on 'Import project'
+
+ expect(Project.count).to eq(1)
+
+ project = Project.last
+ expect(project).not_to be_nil
+ expect(project.description).to eq("Foo Bar")
+ expect(project.issues).not_to be_empty
+ expect(project.merge_requests).not_to be_empty
+ expect(project_hook_exists?(project)).to be true
+ expect(wiki_exists?(project)).to be true
+ expect(project.import_state.status).to eq('finished')
+ end
+ end
+
+ context 'path is not prefilled' do
+ it 'user imports an exported project successfully' do
+ visit new_project_path
+ click_import_project_tab
+ click_link 'GitLab export'
+
+ fill_in :path, with: 'test-project-path', visible: true
+ attach_file('file', file)
+
+ expect { click_on 'Import project' }.to change { Project.count }.by(1)
+
+ project = Project.last
+ expect(project).not_to be_nil
+ expect(page).to have_content("Project 'test-project-path' is being imported")
+ end
+ end
+ end
+
+ it 'invalid project' do
+ project = create(:project, namespace: user.namespace)
+
+ visit new_project_path
+
+ select2(user.namespace.id, from: '#project_namespace_id')
+ fill_in :project_path, with: project.name, visible: true
+ click_import_project_tab
+ click_link 'GitLab export'
+ attach_file('file', file)
+ click_on 'Import project'
+
+ page.within('.flash-container') do
+ expect(page).to have_content('Project could not be imported')
+ end
+ end
+
+ def wiki_exists?(project)
+ wiki = ProjectWiki.new(project)
+ wiki.repository.exists? && !wiki.repository.empty?
+ end
+
+ def project_hook_exists?(project)
+ Gitlab::GitalyClient::StorageSettings.allow_disk_access do
+ Gitlab::Git::Hook.new('post-receive', project.repository.raw_repository).exists?
+ end
+ end
+
+ def click_import_project_tab
+ find('#import-project-tab').click
+ end
+end
diff --git a/spec/features/projects/import_export/import_file_spec.rb b/spec/features/projects/import_export/import_file_spec.rb
index 9cbfb62d872..2d86115de12 100644
--- a/spec/features/projects/import_export/import_file_spec.rb
+++ b/spec/features/projects/import_export/import_file_spec.rb
@@ -8,6 +8,7 @@ describe 'Import/Export - project import integration test', :js do
let(:export_path) { "#{Dir.tmpdir}/import_file_spec" }
before do
+ stub_feature_flags(import_export_object_storage: false)
allow_any_instance_of(Gitlab::ImportExport).to receive(:storage_path).and_return(export_path)
gitlab_sign_in(user)
end