diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-07-05 10:20:03 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-07-05 10:20:03 +0000 |
commit | d2612b42b9da6638d70b9d7144f6d427070d042d (patch) | |
tree | ed7de87d4b112cae8a45ba186d717ca9768c7d4e /spec/uploaders | |
parent | d80373b353005e70f44eca8a3bc4a4c5cfbf0e9e (diff) | |
download | gitlab-ce-d2612b42b9da6638d70b9d7144f6d427070d042d.tar.gz |
Add latest changes from gitlab-org/gitlab@15-1-stable-ee
Diffstat (limited to 'spec/uploaders')
-rw-r--r-- | spec/uploaders/object_storage_spec.rb | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/spec/uploaders/object_storage_spec.rb b/spec/uploaders/object_storage_spec.rb index 13f70e3f85b..1bcc43b81a8 100644 --- a/spec/uploaders/object_storage_spec.rb +++ b/spec/uploaders/object_storage_spec.rb @@ -48,6 +48,28 @@ RSpec.describe ObjectStorage do expect(uploader.store_dir).to start_with("uploads/-/system/user/") end end + + describe '#store_path' do + subject { uploader.store_path('filename') } + + it 'uses store_dir' do + expect(subject).to eq("uploads/-/system/user/#{object.id}/filename") + end + + context 'when a bucket prefix is configured' do + before do + allow(uploader_class).to receive(:object_store_options) do + double( + bucket_prefix: 'my/prefix' + ) + end + end + + it 'uses store_dir and ignores prefix' do + expect(subject).to eq("uploads/-/system/user/#{object.id}/filename") + end + end + end end context 'object_store is Store::REMOTE' do @@ -60,6 +82,28 @@ RSpec.describe ObjectStorage do expect(uploader.store_dir).to start_with("user/") end end + + describe '#store_path' do + subject { uploader.store_path('filename') } + + it 'uses store_dir' do + expect(subject).to eq("user/#{object.id}/filename") + end + + context 'when a bucket prefix is configured' do + before do + allow(uploader_class).to receive(:object_store_options) do + double( + bucket_prefix: 'my/prefix' + ) + end + end + + it 'uses the prefix and store_dir' do + expect(subject).to eq("my/prefix/user/#{object.id}/filename") + end + end + end end end |