diff options
author | Michael Kozono <mkozono@gmail.com> | 2018-08-14 11:20:21 -0700 |
---|---|---|
committer | Jose Vargas <jvargas@gitlab.com> | 2018-08-28 16:36:25 -0500 |
commit | b44ccb283f68c10e33ac6c51b695fd0afd70642a (patch) | |
tree | 0dc809228a2800d6d7e0051c56d49811e3e14149 /spec | |
parent | 4ef1447c4f54af7a609c2a76445704995a29612e (diff) | |
download | gitlab-ce-b44ccb283f68c10e33ac6c51b695fd0afd70642a.tar.gz |
Resolve "Orphaned upload files are accessible via project exports"
Diffstat (limited to 'spec')
-rw-r--r-- | spec/lib/gitlab/import_export/uploads_manager_spec.rb | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/spec/lib/gitlab/import_export/uploads_manager_spec.rb b/spec/lib/gitlab/import_export/uploads_manager_spec.rb index 9c3870a0af8..f799de18cd0 100644 --- a/spec/lib/gitlab/import_export/uploads_manager_spec.rb +++ b/spec/lib/gitlab/import_export/uploads_manager_spec.rb @@ -36,6 +36,38 @@ describe Gitlab::ImportExport::UploadsManager do expect(File).to exist(exported_file_path) end + + context 'with orphaned project upload files' do + let(:orphan_path) { File.join(FileUploader.absolute_base_dir(project), 'f93f088ddf492ffd950cf059002cbbb6', 'orphan.jpg') } + let(:exported_orphan_path) { "#{shared.export_path}/uploads/f93f088ddf492ffd950cf059002cbbb6/orphan.jpg" } + + before do + FileUtils.mkdir_p(File.dirname(orphan_path)) + FileUtils.touch(orphan_path) + end + + after do + File.delete(orphan_path) if File.exist?(orphan_path) + end + + it 'excludes orphaned upload files' do + manager.save + + expect(File).not_to exist(exported_orphan_path) + end + end + + context 'with an upload missing its file' do + before do + File.delete(upload.absolute_path) + end + + it 'does not cause errors' do + manager.save + + expect(shared.errors).to be_empty + end + end end context 'using object storage' do |