summaryrefslogtreecommitdiff
path: root/spec/uploaders
diff options
context:
space:
mode:
authorRémy Coutable <remy@rymai.me>2016-07-12 19:28:39 +0200
committerRémy Coutable <remy@rymai.me>2016-07-20 11:36:42 +0200
commit6b7e9c7655e4ffc74de90f01a0850a230b10a03c (patch)
treeda865eb7dff81588d426907afcc74d6a072fe3fa /spec/uploaders
parent98e540532cc2706e4cdc027bd2acb8406e954ddc (diff)
downloadgitlab-ce-6b7e9c7655e4ffc74de90f01a0850a230b10a03c.tar.gz
Remove VideoJS and clean the integration
Handle videos in: - MD preview in notes: commit, issue/MR, MR diff - New notes in: commit, issue/MR, MR diff - Persisted notes in: commit, issue/MR, MR diff Signed-off-by: Rémy Coutable <remy@rymai.me>
Diffstat (limited to 'spec/uploaders')
-rw-r--r--spec/uploaders/file_uploader_spec.rb59
1 files changed, 31 insertions, 28 deletions
diff --git a/spec/uploaders/file_uploader_spec.rb b/spec/uploaders/file_uploader_spec.rb
index b59f44e0a65..e8300abed5d 100644
--- a/spec/uploaders/file_uploader_spec.rb
+++ b/spec/uploaders/file_uploader_spec.rb
@@ -1,42 +1,45 @@
-require "spec_helper"
-
-# provides matchers like `have_dimensions`
-# https://github.com/carrierwaveuploader/carrierwave#testing-with-carrierwave
-# require "carrierwave/test/matchers"
-
+require 'spec_helper'
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") }
+ let(:project) { create(:project) }
before do
+ @previous_enable_processing = FileUploader.enable_processing
FileUploader.enable_processing = false
@uploader = FileUploader.new(project)
end
after do
- FileUploader.enable_processing = true
+ FileUploader.enable_processing = @previous_enable_processing
@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
+ describe '#image_or_video?' do
+ context 'given an image file' do
+ before do
+ @uploader.store!(File.new(Rails.root.join('spec', 'fixtures', 'rails_sample.jpg')))
+ end
+
+ it 'detects an image based on file extension' do
+ expect(@uploader.image_or_video?).to be true
+ end
+ end
+
+ context 'given an video file' do
+ before do
+ video_file = File.new(Rails.root.join('spec', 'fixtures', 'video_sample.mp4'))
+ @uploader.store!(video_file)
+ end
+
+ it 'detects a video based on file extension' do
+ expect(@uploader.image_or_video?).to be true
+ end
+ end
+
+ it 'does not return image_or_video? for other types' do
+ @uploader.store!(File.new(Rails.root.join('spec', 'fixtures', 'doc_sample.txt')))
+
+ expect(@uploader.image_or_video?).to be false
+ end
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