diff options
author | Bob Van Landuyt <bob@vanlanduyt.co> | 2018-03-30 17:32:21 +0300 |
---|---|---|
committer | Bob Van Landuyt <bob@vanlanduyt.co> | 2018-04-05 11:21:51 +0300 |
commit | 84ee2ddbcd850d29ae852333c57e2e8381f5a535 (patch) | |
tree | 2ca70f7c2efa3c3828a9c4356bcc7d76c3872a67 /spec/lib/gitlab/import_export | |
parent | d5d7bcf8b7404a436c577e2b112aa59dc2901378 (diff) |
Export LFS Objects when exporting a project
The LFS files will be included in the `lfs-objects` directory in the archive.
Diffstat (limited to 'spec/lib/gitlab/import_export')
-rw-r--r-- | spec/lib/gitlab/import_export/lfs_saver_spec.rb | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/spec/lib/gitlab/import_export/lfs_saver_spec.rb b/spec/lib/gitlab/import_export/lfs_saver_spec.rb new file mode 100644 index 00000000000..e2237cd22cf --- /dev/null +++ b/spec/lib/gitlab/import_export/lfs_saver_spec.rb @@ -0,0 +1,39 @@ +require 'spec_helper' + +describe Gitlab::ImportExport::LfsSaver do + let(:shared) { project.import_export_shared } + let(:export_path) { "#{Dir.tmpdir}/project_tree_saver_spec" } + let(:project) { create(:project) } + + subject(:saver) { described_class.new(project: project, shared: shared) } + + before do + allow_any_instance_of(Gitlab::ImportExport).to receive(:storage_path).and_return(export_path) + FileUtils.mkdir_p(shared.export_path) + end + + after do + FileUtils.rm_rf(shared.export_path) + end + + describe '#save' do + context 'when the project has LFS objects' do + let(:lfs_object) { create(:lfs_object, :with_file) } + before do + project.lfs_objects << lfs_object\ + end + + it 'does not cause errors' do + saver.save + + expect(shared.errors).to be_empty + end + + it 'copies the file in the correct location when there is an lfs object' do + saver.save + + expect(File).to exist("#{shared.export_path}/lfs-objects/#{lfs_object.oid}") + end + end + end +end |