diff options
author | Sean McGivern <sean@gitlab.com> | 2019-01-22 12:38:36 +0300 |
---|---|---|
committer | Sean McGivern <sean@gitlab.com> | 2019-01-22 12:38:36 +0300 |
commit | c23534c50f7debf219b282fa3d5777fe750927b0 (patch) | |
tree | 9d800e942a6bd891dbf0c4b7e88044ffc8818545 /spec | |
parent | 60d3fe5804ccb17f0069b51464f5aa3dcc5f63d5 (diff) | |
parent | 940ad0c7a14e7ecff34300737e5802c4956bbb23 (diff) |
Merge branch 'sh-fix-snippet-uploads-path-lookup' into 'master'
Fix 404s with snippet uploads in object storage
Closes #52595
See merge request gitlab-org/gitlab-ce!24550
Diffstat (limited to 'spec')
-rw-r--r-- | spec/uploaders/personal_file_uploader_spec.rb | 32 |
1 files changed, 15 insertions, 17 deletions
diff --git a/spec/uploaders/personal_file_uploader_spec.rb b/spec/uploaders/personal_file_uploader_spec.rb index 2896e9a112d..97758f0243e 100644 --- a/spec/uploaders/personal_file_uploader_spec.rb +++ b/spec/uploaders/personal_file_uploader_spec.rb @@ -4,19 +4,13 @@ describe PersonalFileUploader do let(:model) { create(:personal_snippet) } let(:uploader) { described_class.new(model) } let(:upload) { create(:upload, :personal_snippet_upload) } - let(:identifier) { %r{\h+/\S+} } subject { uploader } - it_behaves_like 'builds correct paths' do - let(:patterns) do - { - store_dir: %r[uploads/-/system/personal_snippet/\d+], - upload_path: identifier, - absolute_path: %r[#{CarrierWave.root}/uploads/-/system/personal_snippet/\d+/#{identifier}] - } - end - end + it_behaves_like 'builds correct paths', + store_dir: %r[uploads/-/system/personal_snippet/\d+], + upload_path: %r[\h+/\S+], + absolute_path: %r[#{CarrierWave.root}/uploads/-/system/personal_snippet\/\d+\/\h+\/\S+$] context "object_store is REMOTE" do before do @@ -25,13 +19,17 @@ describe PersonalFileUploader do include_context 'with storage', described_class::Store::REMOTE - it_behaves_like 'builds correct paths' do - let(:patterns) do - { - store_dir: %r[\d+/\h+], - upload_path: identifier - } - end + it_behaves_like 'builds correct paths', + store_dir: %r[\d+/\h+], + upload_path: %r[^personal_snippet\/\d+\/\h+\/<filename>] + end + + describe '#upload_paths' do + it 'builds correct paths for both local and remote storage' do + paths = uploader.upload_paths('test.jpg') + + expect(paths.first).to match(%r[\h+\/test.jpg]) + expect(paths.second).to match(%r[^personal_snippet\/\d+\/\h+\/test.jpg]) end end |