Sha256: 2010692d60d2513ea98b80bd756b231f4b1c3f0ec3feaa24d59b3fc352a0bced

Contents?: true

Size: 903 Bytes

Versions: 10

Compression:

Stored size: 903 Bytes

Contents

require 'spec_helper'

describe Paperclip::FileCommandContentTypeDetector do
  it 'returns a content type based on the content of the file' do
    tempfile = Tempfile.new("something")
    tempfile.write("This is a file.")
    tempfile.rewind

    assert_equal "text/plain", Paperclip::FileCommandContentTypeDetector.new(tempfile.path).detect

    tempfile.close
  end

  it 'returns a sensible default when the file command is missing' do
    Paperclip.stubs(:run).raises(Cocaine::CommandLineError.new)
    @filename = "/path/to/something"
    assert_equal "application/octet-stream",
      Paperclip::FileCommandContentTypeDetector.new(@filename).detect
  end

  it 'returns a sensible default on the odd chance that run returns nil' do
    Paperclip.stubs(:run).returns(nil)
    assert_equal "application/octet-stream",
      Paperclip::FileCommandContentTypeDetector.new("windows").detect
  end
end

Version data entries

10 entries across 8 versions & 2 rubygems

Version Path
solidus_backend-1.0.0.pre3 vendor/bundle/gems/paperclip-4.2.4/spec/paperclip/file_command_content_type_detector_spec.rb
solidus_backend-1.0.0.pre2 vendor/bundle/gems/paperclip-4.2.4/spec/paperclip/file_command_content_type_detector_spec.rb
solidus_backend-1.0.0.pre vendor/bundle/gems/paperclip-4.2.2/spec/paperclip/file_command_content_type_detector_spec.rb
solidus_backend-1.0.0.pre vendor/bundle/gems/paperclip-4.2.3/spec/paperclip/file_command_content_type_detector_spec.rb
solidus_backend-1.0.0.pre vendor/bundle/gems/paperclip-4.2.4/spec/paperclip/file_command_content_type_detector_spec.rb
paperclip-4.2.4 spec/paperclip/file_command_content_type_detector_spec.rb
paperclip-4.2.3 spec/paperclip/file_command_content_type_detector_spec.rb
paperclip-4.2.2 spec/paperclip/file_command_content_type_detector_spec.rb
paperclip-4.2.1 spec/paperclip/file_command_content_type_detector_spec.rb
paperclip-4.2.0 spec/paperclip/file_command_content_type_detector_spec.rb