summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2019-09-19 03:06:10 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2019-09-19 03:06:10 +0000
commit2c352d252d072549e77d9de71fb9efe7bae94da6 (patch)
tree5db2b4820519bd7b1e808a47c5a2d69de48cbeb2 /spec
parenta7706bcb567ee31c6454c4197354b3210839b564 (diff)
downloadgitlab-ce-2c352d252d072549e77d9de71fb9efe7bae94da6.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec')
-rw-r--r--spec/features/projects/import_export/export_file_spec.rb3
-rw-r--r--spec/lib/gitlab/import_export/after_export_strategies/base_after_export_strategy_spec.rb26
-rw-r--r--spec/lib/gitlab/import_export/shared_spec.rb29
-rw-r--r--spec/requests/api/project_export_spec.rb2
4 files changed, 50 insertions, 10 deletions
diff --git a/spec/features/projects/import_export/export_file_spec.rb b/spec/features/projects/import_export/export_file_spec.rb
index a1002f38936..7618a2bdea3 100644
--- a/spec/features/projects/import_export/export_file_spec.rb
+++ b/spec/features/projects/import_export/export_file_spec.rb
@@ -49,8 +49,7 @@ describe 'Import/Export - project export integration test', :js do
expect(page).to have_content('Download export')
- expect(file_permissions(project.export_path)).to eq(0700)
-
+ expect(project.export_status).to eq(:finished)
expect(project.export_file.path).to include('tar.gz')
in_directory_with_expanded_export(project) do |exit_status, tmpdir|
diff --git a/spec/lib/gitlab/import_export/after_export_strategies/base_after_export_strategy_spec.rb b/spec/lib/gitlab/import_export/after_export_strategies/base_after_export_strategy_spec.rb
index 9a442de2900..a3d2880182d 100644
--- a/spec/lib/gitlab/import_export/after_export_strategies/base_after_export_strategy_spec.rb
+++ b/spec/lib/gitlab/import_export/after_export_strategies/base_after_export_strategy_spec.rb
@@ -24,14 +24,22 @@ describe Gitlab::ImportExport::AfterExportStrategies::BaseAfterExportStrategy do
service.execute(user, project)
- expect(lock_path_exist?).to be_truthy
+ expect(service.locks_present?).to be_truthy
end
context 'when the method succeeds' do
it 'removes the lock file' do
service.execute(user, project)
- expect(lock_path_exist?).to be_falsey
+ expect(service.locks_present?).to be_falsey
+ end
+
+ it 'removes the archive path' do
+ FileUtils.mkdir_p(shared.archive_path)
+
+ service.execute(user, project)
+
+ expect(File.exist?(shared.archive_path)).to be_falsey
end
end
@@ -62,13 +70,21 @@ describe Gitlab::ImportExport::AfterExportStrategies::BaseAfterExportStrategy do
service.execute(user, project)
end
+
+ it 'removes the archive path' do
+ FileUtils.mkdir_p(shared.archive_path)
+
+ service.execute(user, project)
+
+ expect(File.exist?(shared.archive_path)).to be_falsey
+ end
end
context 'when an exception is raised' do
it 'removes the lock' do
expect { service.execute(user, project) }.to raise_error(NotImplementedError)
- expect(lock_path_exist?).to be_falsey
+ expect(service.locks_present?).to be_falsey
end
end
end
@@ -97,8 +113,4 @@ describe Gitlab::ImportExport::AfterExportStrategies::BaseAfterExportStrategy do
expect(described_class.new(params).to_json).to eq result
end
end
-
- def lock_path_exist?
- File.exist?(described_class.lock_file_path(project))
- end
end
diff --git a/spec/lib/gitlab/import_export/shared_spec.rb b/spec/lib/gitlab/import_export/shared_spec.rb
index 2c288cff6ef..da2c96dcf51 100644
--- a/spec/lib/gitlab/import_export/shared_spec.rb
+++ b/spec/lib/gitlab/import_export/shared_spec.rb
@@ -5,6 +5,35 @@ describe Gitlab::ImportExport::Shared do
let(:project) { build(:project) }
subject { project.import_export_shared }
+ context 'with a repository on disk' do
+ let(:project) { create(:project, :repository) }
+ let(:base_path) { %(/tmp/project_exports/#{project.disk_path}/) }
+
+ describe '#archive_path' do
+ it 'uses a random hash to avoid conflicts' do
+ expect(subject.archive_path).to match(/#{base_path}\h{32}/)
+ end
+
+ it 'memoizes the path' do
+ path = subject.archive_path
+
+ 2.times { expect(subject.archive_path).to eq(path) }
+ end
+ end
+
+ describe '#export_path' do
+ it 'uses a random hash relative to project path' do
+ expect(subject.export_path).to match(/#{base_path}\h{32}\/\h{32}/)
+ end
+
+ it 'memoizes the path' do
+ path = subject.export_path
+
+ 2.times { expect(subject.export_path).to eq(path) }
+ end
+ end
+ end
+
describe '#error' do
let(:error) { StandardError.new('Error importing into /my/folder Permission denied @ unlink_internal - /var/opt/gitlab/gitlab-rails/shared/a/b/c/uploads/file') }
diff --git a/spec/requests/api/project_export_spec.rb b/spec/requests/api/project_export_spec.rb
index 1d2f81a397d..7de8935097a 100644
--- a/spec/requests/api/project_export_spec.rb
+++ b/spec/requests/api/project_export_spec.rb
@@ -30,7 +30,7 @@ describe API::ProjectExport do
FileUtils.mkdir_p File.join(project_started.export_path, 'securerandom-hex')
# simulate in after export action
- FileUtils.touch Gitlab::ImportExport::AfterExportStrategies::BaseAfterExportStrategy.lock_file_path(project_after_export)
+ FileUtils.touch File.join(project_after_export.import_export_shared.lock_files_path, SecureRandom.hex)
end
after do