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
path: root/spec/lib
diff options
context:
space:
mode:
authorBob Van Landuyt <bob@vanlanduyt.co>2018-04-03 19:54:42 +0300
committerBob Van Landuyt <bob@vanlanduyt.co>2018-04-05 11:21:51 +0300
commit10d0f438d823418a4a4f4e4f52e8f35ed10f2a05 (patch)
tree326e78434084e6ad547dbe4a727ba4e1c571944c /spec/lib
parent79cb4d99c0e47bfd988788ff38871e668367dfbf (diff)
Download LFS-files from object storage for exports
Downloading the stream directly to the archive. In order to avoid conflicts with the cache.
Diffstat (limited to 'spec/lib')
-rw-r--r--spec/lib/gitlab/import_export/lfs_saver_spec.rb24
1 files changed, 23 insertions, 1 deletions
diff --git a/spec/lib/gitlab/import_export/lfs_saver_spec.rb b/spec/lib/gitlab/import_export/lfs_saver_spec.rb
index e62afac1c48..9b0e21deb2e 100644
--- a/spec/lib/gitlab/import_export/lfs_saver_spec.rb
+++ b/spec/lib/gitlab/import_export/lfs_saver_spec.rb
@@ -17,7 +17,7 @@ describe Gitlab::ImportExport::LfsSaver do
end
describe '#save' do
- context 'when the project has LFS objects' do
+ context 'when the project has LFS objects locally stored' do
let(:lfs_object) { create(:lfs_object, :with_file) }
before do
@@ -36,5 +36,27 @@ describe Gitlab::ImportExport::LfsSaver do
expect(File).to exist("#{shared.export_path}/lfs-objects/#{lfs_object.oid}")
end
end
+
+ context 'when the LFS objects are stored in object storage' do
+ let(:lfs_object) { create(:lfs_object, :object_storage) }
+
+ before do
+ allow(LfsObjectUploader).to receive(:object_store_enabled?).and_return(true)
+ allow(lfs_object.file).to receive(:url).and_return('http://my-object-storage.local')
+ project.lfs_objects << lfs_object
+ end
+
+ it 'downloads the file to include in an archive' do
+ fake_uri = double
+ exported_file_path = "#{shared.export_path}/lfs-objects/#{lfs_object.oid}"
+
+ expect(fake_uri).to receive(:open).and_return(StringIO.new('LFS file content'))
+ expect(URI).to receive(:parse).with('http://my-object-storage.local').and_return(fake_uri)
+
+ saver.save
+
+ expect(File.read(exported_file_path)).to eq('LFS file content')
+ end
+ end
end
end