diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-03-12 18:09:28 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-03-12 18:09:28 +0000 |
commit | ce8a0b90849ac5d1895e741c023432930f24d724 (patch) | |
tree | dbdc97de542cdbe18a2fc8b1a6b64ac0673ed3d3 /spec/uploaders/favicon_uploader_spec.rb | |
parent | dc889678d1de8c09310b2f8f9742bb6c78a6f1a4 (diff) | |
download | gitlab-ce-ce8a0b90849ac5d1895e741c023432930f24d724.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/uploaders/favicon_uploader_spec.rb')
-rw-r--r-- | spec/uploaders/favicon_uploader_spec.rb | 38 |
1 files changed, 27 insertions, 11 deletions
diff --git a/spec/uploaders/favicon_uploader_spec.rb b/spec/uploaders/favicon_uploader_spec.rb index 4d6c849883a..0f5941b3f0a 100644 --- a/spec/uploaders/favicon_uploader_spec.rb +++ b/spec/uploaders/favicon_uploader_spec.rb @@ -6,19 +6,35 @@ describe FaviconUploader do let_it_be(:model) { build_stubbed(:user) } let_it_be(:uploader) { described_class.new(model, :favicon) } - context 'upload type check' do - FaviconUploader::EXTENSION_WHITELIST.each do |ext| - context "#{ext} extension" do - it_behaves_like 'type checked uploads', filenames: "image.#{ext}" - end + context 'accept whitelist file content type' do + include_context 'ignore extension whitelist check' + + # We need to feed through a valid path, but we force the parsed mime type + # in a stub below so we can set any path. + let_it_be(:path) { File.join('spec', 'fixtures', 'video_sample.mp4') } + + where(:mime_type) { described_class::MIME_WHITELIST } + + with_them do + include_context 'force content type detection to mime_type' + + it_behaves_like 'accepted carrierwave upload' end end - context 'upload non-whitelisted file extensions' do - it 'will deny upload' do - path = File.join('spec', 'fixtures', 'banana_sample.gif') - fixture_file = fixture_file_upload(path) - expect { uploader.cache!(fixture_file) }.to raise_exception(CarrierWave::IntegrityError) - end + context 'upload non-whitelisted file content type' do + include_context 'ignore extension whitelist check' + + let_it_be(:path) { File.join('spec', 'fixtures', 'sanitized.svg') } + + it_behaves_like 'denied carrierwave upload' + end + + context 'upload misnamed non-whitelisted file content type' do + include_context 'ignore extension whitelist check' + + let_it_be(:path) { File.join('spec', 'fixtures', 'not_a_png.png') } + + it_behaves_like 'denied carrierwave upload' end end |