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-09-19 04:45:44 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-09-19 04:45:44 +0300
commit85dc423f7090da0a52c73eb66faf22ddb20efff9 (patch)
tree9160f299afd8c80c038f08e1545be119f5e3f1e1 /spec/lib/gitlab/file_type_detection_spec.rb
parent15c2c8c66dbe422588e5411eee7e68f1fa440bb8 (diff)
Add latest changes from gitlab-org/gitlab@13-4-stable-ee
Diffstat (limited to 'spec/lib/gitlab/file_type_detection_spec.rb')
-rw-r--r--spec/lib/gitlab/file_type_detection_spec.rb39
1 files changed, 39 insertions, 0 deletions
diff --git a/spec/lib/gitlab/file_type_detection_spec.rb b/spec/lib/gitlab/file_type_detection_spec.rb
index ba5e7cfabf2..c435d3f6097 100644
--- a/spec/lib/gitlab/file_type_detection_spec.rb
+++ b/spec/lib/gitlab/file_type_detection_spec.rb
@@ -192,6 +192,20 @@ RSpec.describe Gitlab::FileTypeDetection do
end
end
+ describe '#image_safe_for_scaling?' do
+ it 'returns true for allowed image formats' do
+ uploader.store!(upload_fixture('rails_sample.jpg'))
+
+ expect(uploader).to be_image_safe_for_scaling
+ end
+
+ it 'returns false for other files' do
+ uploader.store!(upload_fixture('unsanitized.svg'))
+
+ expect(uploader).not_to be_image_safe_for_scaling
+ end
+ end
+
describe '#dangerous_image?' do
it 'returns true if filename has a dangerous extension' do
uploader.store!(upload_fixture('unsanitized.svg'))
@@ -377,6 +391,31 @@ RSpec.describe Gitlab::FileTypeDetection do
end
end
+ describe '#image_safe_for_scaling?' do
+ using RSpec::Parameterized::TableSyntax
+
+ where(:filename, :expectation) do
+ 'img.jpg' | true
+ 'img.jpeg' | true
+ 'img.png' | true
+ 'img.svg' | false
+ end
+
+ with_them do
+ it "returns expected result" do
+ allow(custom_class).to receive(:filename).and_return(filename)
+
+ expect(custom_class.image_safe_for_scaling?).to be(expectation)
+ end
+ end
+
+ it 'returns false if filename is blank' do
+ allow(custom_class).to receive(:filename).and_return(nil)
+
+ expect(custom_class).not_to be_image_safe_for_scaling
+ end
+ end
+
describe '#video?' do
it 'returns true for a video file' do
allow(custom_class).to receive(:filename).and_return('video_sample.mp4')