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

file_uploader_spec.rb « uploaders « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: b59f44e0a65935331403e6f1c60c918c11c8cd37 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
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