mirror of
https://github.com/kemko/paperclip.git
synced 2026-01-01 16:05:40 +03:00
Upfile tests + File#size is available since ruby 2.0 (AR 5 requires 2.2)
This commit is contained in:
@@ -39,11 +39,6 @@ module Paperclip
|
||||
def original_filename
|
||||
@original_filename ||= File.basename(path)
|
||||
end
|
||||
|
||||
# Returns the size of the file.
|
||||
def size
|
||||
File.size(self)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
42
test/upfile_test.rb
Normal file
42
test/upfile_test.rb
Normal file
@@ -0,0 +1,42 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'test_helper'
|
||||
|
||||
class UpfileTest < Test::Unit::TestCase
|
||||
context "content_type_from_ext" do
|
||||
{
|
||||
'lala' => 'application/x-octet-stream',
|
||||
'lala.foo' => 'application/x-foo',
|
||||
'__.jpg' => "image/jpeg",
|
||||
'_.jpeg' => "image/jpeg",
|
||||
'__.tif' => "image/tiff",
|
||||
'_.tiff' => "image/tiff",
|
||||
|
||||
'_.png' => "image/png",
|
||||
'_.gif' => "image/gif",
|
||||
'_.bmp' => "image/bmp",
|
||||
"_.webp" => "image/webp",
|
||||
|
||||
# '_.pngfoo' => 'application/x-pngfoo', # ??
|
||||
# '_.htmfoo' => 'application/x-htmfoo', # ?
|
||||
|
||||
'_.csv' => "text/csv",
|
||||
'_.xml' => "text/xml",
|
||||
'_.css' => "text/css",
|
||||
'_.js' => "text/js", # ???
|
||||
|
||||
'_.html' => 'text/html',
|
||||
'__.htm' => 'text/html',
|
||||
|
||||
|
||||
"_.txt" => "text/plain",
|
||||
"_.liquid" => "text/x-liquid",
|
||||
'_.svg' => 'image/svg+xml',
|
||||
'_.xls' => 'application/vnd.ms-excel',
|
||||
}.each_pair do |example, result|
|
||||
should "return #{result} for #{example}" do
|
||||
assert_equal result, Paperclip::Upfile.content_type_from_ext(example)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user