debian-mirror-gitlab/spec/uploaders/import_export_uploader_spec.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

94 lines
2.4 KiB
Ruby
Raw Normal View History

2019-12-21 20:55:43 +05:30
# frozen_string_literal: true
2018-11-08 19:23:39 +05:30
require 'spec_helper'
2020-07-28 23:09:34 +05:30
RSpec.describe ImportExportUploader do
2018-11-08 19:23:39 +05:30
let(:model) { build_stubbed(:import_export_upload) }
let(:upload) { create(:upload, model: model) }
2019-07-31 22:56:46 +05:30
let(:import_export_upload) { ImportExportUpload.new }
2018-11-08 19:23:39 +05:30
2019-03-02 22:35:43 +05:30
subject { described_class.new(model, :import_file) }
2018-11-08 19:23:39 +05:30
2019-07-31 22:56:46 +05:30
context 'local store' do
2022-04-04 11:22:00 +05:30
describe '#move_to_cache' do
it 'returns false' do
expect(subject.move_to_cache).to be false
end
context 'with project export' do
subject { described_class.new(model, :export_file) }
it 'returns true' do
expect(subject.move_to_cache).to be true
end
end
end
2019-07-31 22:56:46 +05:30
describe '#move_to_store' do
it 'returns true' do
expect(subject.move_to_store).to be true
end
end
end
2018-11-08 19:23:39 +05:30
context "object_store is REMOTE" do
before do
stub_uploads_object_storage
end
include_context 'with storage', described_class::Store::REMOTE
2020-11-05 12:06:23 +05:30
patterns = {
store_dir: %r[import_export_upload/import_file/],
upload_path: %r[import_export_upload/import_file/]
}
it_behaves_like 'builds correct paths', patterns do
let(:fixture) { File.join('spec', 'fixtures', 'group_export.tar.gz') }
end
2019-07-31 22:56:46 +05:30
2022-04-04 11:22:00 +05:30
describe '#move_to_cache' do
it 'returns false' do
expect(subject.move_to_cache).to be false
end
context 'with project export' do
subject { described_class.new(model, :export_file) }
it 'returns true' do
expect(subject.move_to_cache).to be false
end
end
end
2019-07-31 22:56:46 +05:30
describe '#move_to_store' do
it 'returns false' do
expect(subject.move_to_store).to be false
end
end
describe 'with an export file directly uploaded' do
let(:tempfile) { Tempfile.new(['test', '.gz']) }
before do
stub_uploads_object_storage(described_class, direct_upload: true)
import_export_upload.export_file = tempfile
end
it 'cleans up cached file' do
cache_dir = File.join(import_export_upload.export_file.cache_path(nil), '*')
import_export_upload.save!
expect(Dir[cache_dir]).to be_empty
end
end
2018-11-08 19:23:39 +05:30
end
2020-03-13 15:44:24 +05:30
describe '.workhorse_local_upload_path' do
it 'returns path that includes uploads dir' do
expect(described_class.workhorse_local_upload_path).to end_with('/uploads/tmp/uploads')
end
end
2018-11-08 19:23:39 +05:30
end