diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-03-12 21:09:28 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-03-12 21:09:28 +0300 |
commit | ce8a0b90849ac5d1895e741c023432930f24d724 (patch) | |
tree | dbdc97de542cdbe18a2fc8b1a6b64ac0673ed3d3 /spec/uploaders/content_type_whitelist_spec.rb | |
parent | dc889678d1de8c09310b2f8f9742bb6c78a6f1a4 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/uploaders/content_type_whitelist_spec.rb')
-rw-r--r-- | spec/uploaders/content_type_whitelist_spec.rb | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/spec/uploaders/content_type_whitelist_spec.rb b/spec/uploaders/content_type_whitelist_spec.rb new file mode 100644 index 00000000000..be519ead1c8 --- /dev/null +++ b/spec/uploaders/content_type_whitelist_spec.rb @@ -0,0 +1,34 @@ +# frozen_string_literal: true + +require 'spec_helper' + +describe ContentTypeWhitelist do + class DummyUploader < CarrierWave::Uploader::Base + include ContentTypeWhitelist::Concern + + def content_type_whitelist + %w[image/png image/jpeg] + end + end + + let_it_be(:model) { build_stubbed(:user) } + let_it_be(:uploader) { DummyUploader.new(model, :dummy) } + + context 'upload whitelisted file content type' do + let(:path) { File.join('spec', 'fixtures', 'rails_sample.jpg') } + + it_behaves_like 'accepted carrierwave upload' + end + + context 'upload non-whitelisted file content type' do + let(:path) { File.join('spec', 'fixtures', 'sanitized.svg') } + + it_behaves_like 'denied carrierwave upload' + end + + context 'upload misnamed non-whitelisted file content type' do + let(:path) { File.join('spec', 'fixtures', 'not_a_png.png') } + + it_behaves_like 'denied carrierwave upload' + end +end |