debian-mirror-gitlab/spec/uploaders/favicon_uploader_spec.rb

41 lines
1.2 KiB
Ruby
Raw Normal View History

2020-03-13 15:44:24 +05:30
# frozen_string_literal: true
require 'spec_helper'
2020-07-28 23:09:34 +05:30
RSpec.describe FaviconUploader do
2020-03-13 15:44:24 +05:30
let_it_be(:model) { build_stubbed(:user) }
let_it_be(:uploader) { described_class.new(model, :favicon) }
2020-04-08 14:13:33 +05:30
context 'accept whitelist file content type' do
2022-08-27 11:52:29 +05:30
include_context 'ignore extension allowlist check'
2020-04-08 14:13:33 +05:30
# 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') }
2022-08-27 11:52:29 +05:30
where(:mime_type) { described_class::MIME_ALLOWLIST }
2020-04-08 14:13:33 +05:30
with_them do
include_context 'force content type detection to mime_type'
it_behaves_like 'accepted carrierwave upload'
2020-03-13 15:44:24 +05:30
end
end
2020-04-08 14:13:33 +05:30
context 'upload non-whitelisted file content type' do
2022-08-27 11:52:29 +05:30
include_context 'ignore extension allowlist check'
2020-04-08 14:13:33 +05:30
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
2022-08-27 11:52:29 +05:30
include_context 'ignore extension allowlist check'
2020-04-08 14:13:33 +05:30
let_it_be(:path) { File.join('spec', 'fixtures', 'not_a_png.png') }
it_behaves_like 'denied carrierwave upload'
2020-03-13 15:44:24 +05:30
end
end