summaryrefslogtreecommitdiff
path: root/spec/uploaders
diff options
context:
space:
mode:
authorEric Hayes <eric@erichayes.net>2016-04-02 22:00:06 -0700
committerRémy Coutable <remy@rymai.me>2016-07-19 18:51:09 +0200
commitc266c7fa18848586cd6ee903cc4c4d4f9049100e (patch)
tree8fa8d0b2dca828bec6af0ad49855cbb4e69a9e30 /spec/uploaders
parent81e57e783e8882de21d27d9191c09404ed7faca3 (diff)
downloadgitlab-ce-c266c7fa18848586cd6ee903cc4c4d4f9049100e.tar.gz
First support of videos in issues, MRs and notes
* Registered video MIME types * Currently supporting browser-supported formats with extensions that match the mime type
Diffstat (limited to 'spec/uploaders')
-rw-r--r--spec/uploaders/file_uploader_spec.rb42
1 files changed, 42 insertions, 0 deletions
diff --git a/spec/uploaders/file_uploader_spec.rb b/spec/uploaders/file_uploader_spec.rb
new file mode 100644
index 00000000000..b59f44e0a65
--- /dev/null
+++ b/spec/uploaders/file_uploader_spec.rb
@@ -0,0 +1,42 @@
+require "spec_helper"
+
+# provides matchers like `have_dimensions`
+# https://github.com/carrierwaveuploader/carrierwave#testing-with-carrierwave
+# require "carrierwave/test/matchers"
+
+
+describe FileUploader do
+ # include CarrierWave::Test::Matchers
+
+ let(:project){ create(:project) }
+
+ let(:image_file){ File.new Rails.root.join("spec", "fixtures", "rails_sample.jpg") }
+ let(:video_file){ File.new Rails.root.join("spec", "fixtures", "video_sample.mp4") }
+ let(:text_file) { File.new Rails.root.join("spec", "fixtures", "doc_sample.txt") }
+
+ before do
+ FileUploader.enable_processing = false
+ @uploader = FileUploader.new(project)
+ end
+
+ after do
+ FileUploader.enable_processing = true
+ @uploader.remove!
+ end
+
+ it "should detect an image based on file extension" do
+ @uploader.store!(image_file)
+ expect(@uploader.image_or_video?).to be true
+ end
+
+ it "should detect a video based on file extension" do
+ @uploader.store!(video_file)
+ expect(@uploader.image_or_video?).to be true
+ end
+
+ it "should not return image_or_video? for other types" do
+ @uploader.store!(text_file)
+ expect(@uploader.image_or_video?).to be false
+ end
+
+end