2020-01-01 13:55:28 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-11-08 19:23:39 +05:30
|
|
|
require 'spec_helper'
|
|
|
|
require 'fileutils'
|
|
|
|
|
|
|
|
describe Gitlab::ImportExport::Saver do
|
|
|
|
let!(:project) { create(:project, :public, name: 'project') }
|
|
|
|
let(:export_path) { "#{Dir.tmpdir}/project_tree_saver_spec" }
|
|
|
|
let(:shared) { project.import_export_shared }
|
2020-01-01 13:55:28 +05:30
|
|
|
|
2019-12-26 22:10:19 +05:30
|
|
|
subject { described_class.new(exportable: project, shared: shared) }
|
2018-11-08 19:23:39 +05:30
|
|
|
|
|
|
|
before do
|
2020-01-01 13:55:28 +05:30
|
|
|
allow_next_instance_of(Gitlab::ImportExport) do |instance|
|
|
|
|
allow(instance).to receive(:storage_path).and_return(export_path)
|
|
|
|
end
|
2018-11-08 19:23:39 +05:30
|
|
|
|
|
|
|
FileUtils.mkdir_p(shared.export_path)
|
|
|
|
FileUtils.touch("#{shared.export_path}/tmp.bundle")
|
|
|
|
end
|
|
|
|
|
|
|
|
after do
|
|
|
|
FileUtils.rm_rf(export_path)
|
|
|
|
end
|
|
|
|
|
2018-11-20 20:47:30 +05:30
|
|
|
it 'saves the repo using object storage' do
|
|
|
|
stub_uploads_object_storage(ImportExportUploader)
|
2018-11-08 19:23:39 +05:30
|
|
|
|
2018-11-20 20:47:30 +05:30
|
|
|
subject.save
|
2018-11-08 19:23:39 +05:30
|
|
|
|
2018-11-20 20:47:30 +05:30
|
|
|
expect(ImportExportUpload.find_by(project: project).export_file.url)
|
|
|
|
.to match(%r[\/uploads\/-\/system\/import_export_upload\/export_file.*])
|
2018-11-08 19:23:39 +05:30
|
|
|
end
|
|
|
|
end
|