Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-02-22 00:08:57 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-02-22 00:08:57 +0300
commita6c2be7cd20a9515b347e72d63c5b47bb9b79457 (patch)
tree568212b4debeb2a35bb1133209b98e1468d9ee85 /spec/lib/gitlab/file_type_detection_spec.rb
parent74a2d57b337034cfdcd719615e4da06643b69114 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/lib/gitlab/file_type_detection_spec.rb')
-rw-r--r--spec/lib/gitlab/file_type_detection_spec.rb29
1 files changed, 29 insertions, 0 deletions
diff --git a/spec/lib/gitlab/file_type_detection_spec.rb b/spec/lib/gitlab/file_type_detection_spec.rb
index 05008bf895c..2f1fc57c559 100644
--- a/spec/lib/gitlab/file_type_detection_spec.rb
+++ b/spec/lib/gitlab/file_type_detection_spec.rb
@@ -2,6 +2,35 @@
require 'spec_helper'
describe Gitlab::FileTypeDetection do
+ describe '.extension_match?' do
+ let(:extensions) { %w[foo bar] }
+
+ it 'returns false when filename is blank' do
+ expect(described_class.extension_match?(nil, extensions)).to eq(false)
+ expect(described_class.extension_match?('', extensions)).to eq(false)
+ end
+
+ it 'returns true when filename matches extensions' do
+ expect(described_class.extension_match?('file.foo', extensions)).to eq(true)
+ expect(described_class.extension_match?('file.bar', extensions)).to eq(true)
+ end
+
+ it 'returns false when filename does not match extensions' do
+ expect(described_class.extension_match?('file.baz', extensions)).to eq(false)
+ end
+
+ it 'can match case insensitive filenames' do
+ expect(described_class.extension_match?('file.FOO', extensions)).to eq(true)
+ end
+
+ it 'can match filenames with periods' do
+ expect(described_class.extension_match?('my.file.foo', extensions)).to eq(true)
+ end
+
+ it 'can match filenames with directories' do
+ expect(described_class.extension_match?('my/file.foo', extensions)).to eq(true)
+ end
+ end
context 'when class is an uploader' do
let(:uploader) do
example_uploader = Class.new(CarrierWave::Uploader::Base) do