PageRenderTime 143ms CodeModel.GetById 31ms RepoModel.GetById 9ms app.codeStats 0ms

/amexsbs/railsapp/vendor/plugins/paperclip/test/upfile_test.rb

https://bitbucket.org/AcireStudios/social-app-demo
Ruby | 36 lines | 33 code | 3 blank | 0 comment | 0 complexity | da3f6cb10815ad31c82a779d98eebba7 MD5 | raw file
Possible License(s): GPL-2.0, MPL-2.0-no-copyleft-exception, MIT
  1. require 'test/helper'
  2. class UpfileTest < Test::Unit::TestCase
  3. { %w(jpg jpe jpeg) => 'image/jpeg',
  4. %w(tif tiff) => 'image/tiff',
  5. %w(png) => 'image/png',
  6. %w(gif) => 'image/gif',
  7. %w(bmp) => 'image/bmp',
  8. %w(txt) => 'text/plain',
  9. %w(htm html) => 'text/html',
  10. %w(csv) => 'text/csv',
  11. %w(xml) => 'text/xml',
  12. %w(css) => 'text/css',
  13. %w(js) => 'application/js',
  14. %w(foo) => 'application/x-foo'
  15. }.each do |extensions, content_type|
  16. extensions.each do |extension|
  17. should "return a content_type of #{content_type} for a file with extension .#{extension}" do
  18. file = stub('file', :path => "basename.#{extension}")
  19. class << file
  20. include Paperclip::Upfile
  21. end
  22. assert_equal content_type, file.content_type
  23. end
  24. end
  25. end
  26. should "return a content_type of text/plain on a real file whose content_type is determined with the file command" do
  27. file = File.new(File.join(File.dirname(__FILE__), "..", "LICENSE"))
  28. class << file
  29. include Paperclip::Upfile
  30. end
  31. assert_equal 'text/plain', file.content_type
  32. end
  33. end