a8c62dfe5c
- Moves a duplicate `file_storage?` definition into the common `GitlabUploader` ancestor. - Get the `uploads` base directory from a class method rather than hard-coding it where it's needed. This will be used in a subsequent MR to store Uploads in the database. - Improves the specs for uploaders.
35 lines
816 B
Ruby
35 lines
816 B
Ruby
require 'rails_helper'
|
|
|
|
describe UploaderHelper do
|
|
class ExampleUploader < CarrierWave::Uploader::Base
|
|
include UploaderHelper
|
|
|
|
storage :file
|
|
end
|
|
|
|
def upload_fixture(filename)
|
|
fixture_file_upload(Rails.root.join('spec', 'fixtures', filename))
|
|
end
|
|
|
|
describe '#image_or_video?' do
|
|
let(:uploader) { ExampleUploader.new }
|
|
|
|
it 'returns true for an image file' do
|
|
uploader.store!(upload_fixture('dk.png'))
|
|
|
|
expect(uploader).to be_image_or_video
|
|
end
|
|
|
|
it 'it returns true for a video file' do
|
|
uploader.store!(upload_fixture('video_sample.mp4'))
|
|
|
|
expect(uploader).to be_image_or_video
|
|
end
|
|
|
|
it 'returns false for other extensions' do
|
|
uploader.store!(upload_fixture('doc_sample.txt'))
|
|
|
|
expect(uploader).not_to be_image_or_video
|
|
end
|
|
end
|
|
end
|