Sha256: f820f747b423a7126bfa3d3600010551d1b60e99d08dec274cfe36eb1426b045

Contents?: true

Size: 1.18 KB

Versions: 15

Compression:

Stored size: 1.18 KB

Contents

require 'test/helper'

class UpfileTest < Test::Unit::TestCase
  { %w(jpg jpe jpeg) => 'image/jpeg',
    %w(tif tiff)     => 'image/tiff',
    %w(png)          => 'image/png',
    %w(gif)          => 'image/gif',
    %w(bmp)          => 'image/bmp',
    %w(txt)          => 'text/plain',
    %w(htm html)     => 'text/html',
    %w(csv)          => 'text/csv',
    %w(xml)          => 'text/xml',
    %w(css)          => 'text/css',
    %w(js)           => 'application/js',
    %w(foo)          => 'application/x-foo'
  }.each do |extensions, content_type|
    extensions.each do |extension|
      should "return a content_type of #{content_type} for a file with extension .#{extension}" do
        file = stub('file', :path => "basename.#{extension}")
        class << file
          include Paperclip::Upfile
        end

        assert_equal content_type, file.content_type
      end
    end
  end

  should "return a content_type of text/plain on a real file whose content_type is determined with the file command" do
    file = File.new(File.join(File.dirname(__FILE__), "..", "LICENSE"))
    class << file
      include Paperclip::Upfile
    end
    assert_equal 'text/plain', file.content_type
  end
end

Version data entries

15 entries across 15 versions & 8 rubygems

Version Path
olek-paperclip-2.3.3.2 test/upfile_test.rb
olek-paperclip-2.3.3.1 test/upfile_test.rb
radiant-paperclipped-extension-0.8.1 vendor/plugins/paperclip/test/upfile_test.rb
path-paperclip-2.3.3 test/upfile_test.rb
paperclip-2.3.4 test/upfile_test.rb
bookis-paperclip-2.3.3.1 test/upfile_test.rb
bookis-paperclip-2.3.3 test/upfile_test.rb
olek-paperclip-2.3.3 test/upfile_test.rb
davidray-paperclip-2.3.3 test/upfile_test.rb
mbailey-paperclip-2.3.3 test/upfile_test.rb
mbailey-paperclip-2.3.2.1 test/upfile_test.rb
mbailey-paperclip-2.3.2 test/upfile_test.rb
paperclip-2.3.3 test/upfile_test.rb
paperclip-2.3.2 test/upfile_test.rb
paperclip-cloudfiles-2.3.2 test/upfile_test.rb