diff options
author | Micaƫl Bergeron <mbergeron@gitlab.com> | 2018-06-28 10:57:28 -0400 |
---|---|---|
committer | Stan Hu <stanhu@gmail.com> | 2018-07-03 09:57:15 -0700 |
commit | cebdd267e672c75696cd534bb89d10fda8de129f (patch) | |
tree | ae1acb12eec102ac3c7cf0769dfaaa4df29c4a1b /spec/uploaders | |
parent | e61f66b3d16cf097af8fbf3072018fd7d9ec8b67 (diff) | |
download | gitlab-ce-cebdd267e672c75696cd534bb89d10fda8de129f.tar.gz |
add support for file copy on object storage
Diffstat (limited to 'spec/uploaders')
-rw-r--r-- | spec/uploaders/file_uploader_spec.rb | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/spec/uploaders/file_uploader_spec.rb b/spec/uploaders/file_uploader_spec.rb index 59013a02938..1206b94b635 100644 --- a/spec/uploaders/file_uploader_spec.rb +++ b/spec/uploaders/file_uploader_spec.rb @@ -80,6 +80,50 @@ describe FileUploader do end end + describe 'copy_to' do + shared_examples 'returns a valid uploader' do + describe 'returned uploader' do + let(:new_project) { create(:project) } + let(:moved) { described_class.copy_to(subject, new_project) } + + it 'generates a new secret' do + expect(subject).to be + expect(described_class).to receive(:generate_secret).once.and_call_original + expect(moved).to be + end + + it 'create new upload' do + expect(moved.upload).not_to eq(subject.upload) + end + + it 'copies the file' do + expect(subject.file).to exist + expect(moved.file).to exist + expect(subject.file).not_to eq(moved.file) + expect(subject.object_store).to eq(moved.object_store) + end + end + end + + context 'files are store locally' do + include_examples 'returns a valid uploader' + + before do + subject.store!(fixture_file_upload('spec/fixtures/dk.png')) + end + end + + context 'files are stored remotely' do + before do + stub_uploads_object_storage + subject.store!(fixture_file_upload('spec/fixtures/dk.png')) + subject.migrate!(ObjectStorage::Store::REMOTE) + end + + include_examples 'returns a valid uploader' + end + end + describe '#secret' do it 'generates a secret if none is provided' do expect(described_class).to receive(:generate_secret).and_return('secret') |