Default to not binary

This commit is contained in:
Joshua Peek
2011-06-02 15:20:50 -05:00
parent a12bde58e0
commit d9990aed06
4 changed files with 87 additions and 9 deletions

View File

@@ -25,8 +25,9 @@ class TestBlob < Test::Unit::TestCase
def test_mime_type
assert_equal "application/ruby", blob("grit.rb").mime_type
assert_equal "application/xml", blob("bar.xml").mime_type
assert_equal "text/plain", blob("dog.o").mime_type
assert_equal "application/octet-stream", blob("dog.o").mime_type
assert_equal "application/sh", blob("script.sh").mime_type
assert_equal "text/plain", blob("README").mime_type
end
def test_content_type
@@ -35,6 +36,7 @@ class TestBlob < Test::Unit::TestCase
assert_equal "text/plain; charset=utf-8", blob("bar.xml").content_type
assert_equal "application/octet-stream", blob("dog.o").content_type
assert_equal "text/plain; charset=utf-8", blob("script.sh").content_type
assert_equal "text/plain; charset=utf-8", blob("README").content_type
end
def test_disposition
@@ -43,6 +45,7 @@ class TestBlob < Test::Unit::TestCase
assert_equal "attachment; filename=foo+bar.jar", blob("foo bar.jar").disposition
assert_equal "inline", blob("foo.txt").disposition
assert_equal "inline", blob("grit.rb").disposition
assert_equal "inline", blob("README").disposition
end
def test_data
@@ -69,6 +72,7 @@ class TestBlob < Test::Unit::TestCase
assert blob("linguist.gem").binary?
assert blob("git.deb").binary?
assert blob("git.exe").binary?
assert !blob("README").binary?
assert !blob("file.txt").binary?
assert !blob("foo.rb").binary?
assert !blob("octocat.png").binary?
@@ -76,8 +80,9 @@ class TestBlob < Test::Unit::TestCase
end
def test_text
assert blob("file.txt").text?
assert blob("README").text?
assert blob("file.json").text?
assert blob("file.txt").text?
assert blob("script.sh").text?
end
@@ -90,10 +95,11 @@ class TestBlob < Test::Unit::TestCase
end
def test_viewable
assert blob("README").viewable?
assert blob("foo.rb").viewable?
assert blob("script.pl").viewable?
assert !blob("octocat.png").viewable?
assert !blob("linguist.gem").viewable?
assert !blob("octocat.png").viewable?
end
def test_generated
@@ -210,6 +216,8 @@ class TestBlob < Test::Unit::TestCase
assert_equal Language['VimL'], blob(".gvimrc").language
assert_equal Language['INI'], blob(".gitconfig").language
assert_equal Language['YAML'], blob(".gemrc").language
assert_equal Language['Text'], blob("README").language
end
def test_lexer

View File

@@ -7,6 +7,7 @@ class TestMime < Test::Unit::TestCase
def test_mime
assert_equal 'text/plain', Mime.mime_for(nil)
assert_equal 'text/plain', Mime.mime_for("")
assert_equal 'application/ruby', Mime.mime_for(".rb")
assert_equal 'application/javascript', Mime.mime_for(".js")
@@ -14,11 +15,19 @@ class TestMime < Test::Unit::TestCase
assert_equal 'text/plain', Mime.mime_for(".kt")
assert_equal 'text/html', Mime.mime_for(".html")
assert_equal 'text/cache-manifest', Mime.mime_for(".manifest")
assert_equal 'application/sh', Mime.mime_for(".sh")
assert_equal 'application/latex', Mime.mime_for(".latex")
assert_equal 'application/vnd.adobe.air-application-installer-package+zip',
Mime.mime_for(".air")
assert_equal 'application/shockwave-flash', Mime.mime_for(".swf")
assert_equal 'application/chrome-extension', Mime.mime_for(".crx")
assert_equal 'application/debian-package', Mime.mime_for(".deb")
assert_equal 'video/quicktime', Mime.mime_for(".mov")
assert_equal 'application/octet-stream', Mime.mime_for(".dmg")
assert_equal 'application/octet-stream', Mime.mime_for(".exe")
assert_equal 'application/octet-stream', Mime.mime_for(".dll")
@@ -30,6 +39,7 @@ class TestMime < Test::Unit::TestCase
def test_content_type
assert_equal 'text/plain; charset=utf-8', Mime.content_type_for(nil)
assert_equal 'text/plain; charset=utf-8', Mime.content_type_for("")
assert_equal 'text/plain; charset=utf-8', Mime.content_type_for(".rb")
assert_equal 'text/plain; charset=utf-8', Mime.content_type_for(".js")
@@ -40,10 +50,11 @@ class TestMime < Test::Unit::TestCase
assert_equal 'text/plain; charset=utf-8', Mime.content_type_for(".sh")
assert_equal 'text/plain; charset=utf-8', Mime.content_type_for(".latex")
assert_equal 'application/octet-stream', Mime.content_type_for(".swf")
assert_equal 'application/octet-stream', Mime.content_type_for(".air")
assert_equal 'application/octet-stream', Mime.content_type_for(".dll")
assert_equal 'application/octet-stream', Mime.content_type_for(".dmg")
assert_equal 'application/octet-stream', Mime.content_type_for(".exe")
assert_equal 'application/octet-stream', Mime.content_type_for(".dll")
assert_equal 'application/octet-stream', Mime.content_type_for(".swf")
assert_equal 'application/java-archive', Mime.content_type_for(".jar")
assert_equal 'application/java-archive', Mime.content_type_for(".ear")
@@ -51,6 +62,9 @@ class TestMime < Test::Unit::TestCase
end
def test_binary
assert !Mime.binary?(nil)
assert !Mime.binary?("")
assert Mime.binary?("application/octet-stream")
assert !Mime.binary?("text/plain")
@@ -58,13 +72,12 @@ class TestMime < Test::Unit::TestCase
assert Mime.binary?("application/ogg")
assert Mime.binary?("application/pdf")
assert Mime.binary?("application/x-gzip")
assert Mime.binary?("application/x-shockwave-flash")
assert Mime.binary?("application/zip")
assert Mime.binary?("audio/mp4")
assert Mime.binary?("image/gif")
assert Mime.binary?("image/jpeg")
assert Mime.binary?("image/png")
assert Mime.binary?("java-archive")
assert Mime.binary?("x-shockwave-flash")
assert Mime.binary?(".a")
assert Mime.binary?(".air")