debian-mirror-gitlab/spec/support/shared_contexts/upload_type_check_shared_context.rb

20 lines
748 B
Ruby
Raw Normal View History

2020-03-13 15:44:24 +05:30
# frozen_string_literal: true
# Construct an `uploader` variable that is configured to `check_upload_type`
# with `mime_types` and `extensions`.
2020-04-08 14:13:33 +05:30
# @param uploader [CarrierWave::Uploader::Base] uploader with extension_whitelist method.
RSpec.shared_context 'ignore extension whitelist check' do
before do
allow(uploader).to receive(:extension_whitelist).and_return(nil)
2020-03-13 15:44:24 +05:30
end
end
2020-04-08 14:13:33 +05:30
# This works with a content_type_whitelist and content_type_blacklist type check.
# @param mime_type [String] mime type to forcibly detect.
RSpec.shared_context 'force content type detection to mime_type' do
2020-03-13 15:44:24 +05:30
before do
2020-04-08 14:13:33 +05:30
magic_mime_obj = MimeMagic.new(mime_type)
2020-03-13 15:44:24 +05:30
allow(MimeMagic).to receive(:by_magic).with(anything).and_return(magic_mime_obj)
end
end