diff options
author | Sean McGivern <sean@mcgivern.me.uk> | 2018-03-02 15:41:40 +0000 |
---|---|---|
committer | Micaƫl Bergeron <mbergeron@gitlab.com> | 2018-03-08 09:25:56 -0500 |
commit | 2387ef2b4a9944749f0cd1db5c7e7f55f3745780 (patch) | |
tree | af51290e8b3e26f702bbd320eeb194126470fa44 /spec/uploaders | |
parent | 960b6337cbaaf6a7dad2232c3722010f305eee82 (diff) | |
download | gitlab-ce-2387ef2b4a9944749f0cd1db5c7e7f55f3745780.tar.gz |
Merge branch 'poc-upload-hashing-path' into 'master'
File uploads on objects storage should use hashed storage
Closes #4952
See merge request gitlab-org/gitlab-ee!4597
Diffstat (limited to 'spec/uploaders')
-rw-r--r-- | spec/uploaders/file_uploader_spec.rb | 38 |
1 files changed, 18 insertions, 20 deletions
diff --git a/spec/uploaders/file_uploader_spec.rb b/spec/uploaders/file_uploader_spec.rb index 4b7dcbeda33..db2810bbe1d 100644 --- a/spec/uploaders/file_uploader_spec.rb +++ b/spec/uploaders/file_uploader_spec.rb @@ -11,34 +11,30 @@ describe FileUploader do shared_examples 'builds correct legacy storage paths' do include_examples 'builds correct paths', store_dir: %r{awesome/project/\h+}, + upload_path: %r{\h+/<filename>}, absolute_path: %r{#{described_class.root}/awesome/project/secret/foo.jpg} end - shared_examples 'uses hashed storage' do - context 'when rolled out attachments' do - let(:project) { build_stubbed(:project, namespace: group, name: 'project') } + context 'legacy storage' do + it_behaves_like 'builds correct legacy storage paths' - before do - allow(project).to receive(:disk_path).and_return('ca/fe/fe/ed') - end + context 'uses hashed storage' do + context 'when rolled out attachments' do + let(:project) { build_stubbed(:project, namespace: group, name: 'project') } - it_behaves_like 'builds correct paths', - store_dir: %r{ca/fe/fe/ed/\h+}, - absolute_path: %r{#{described_class.root}/ca/fe/fe/ed/secret/foo.jpg} - end + include_examples 'builds correct paths', + store_dir: %r{@hashed/\h{2}/\h{2}/\h+}, + upload_path: %r{\h+/<filename>} + end - context 'when only repositories are rolled out' do - let(:project) { build_stubbed(:project, namespace: group, name: 'project', storage_version: Project::HASHED_STORAGE_FEATURES[:repository]) } + context 'when only repositories are rolled out' do + let(:project) { build_stubbed(:project, namespace: group, name: 'project', storage_version: Project::HASHED_STORAGE_FEATURES[:repository]) } - it_behaves_like 'builds correct legacy storage paths' + it_behaves_like 'builds correct legacy storage paths' + end end end - context 'legacy storage' do - it_behaves_like 'builds correct legacy storage paths' - include_examples 'uses hashed storage' - end - context 'object store is remote' do before do stub_uploads_object_storage @@ -46,8 +42,10 @@ describe FileUploader do include_context 'with storage', described_class::Store::REMOTE - it_behaves_like 'builds correct legacy storage paths' - include_examples 'uses hashed storage' + # always use hashed storage path for remote uploads + it_behaves_like 'builds correct paths', + store_dir: %r{@hashed/\h{2}/\h{2}/\h+}, + upload_path: %r{@hashed/\h{2}/\h{2}/\h+/\h+/<filename>} end describe 'initialize' do |