Permalink
Browse files

Remove register_mime_type

  • Loading branch information...
1 parent 1f87cc9 commit c246dc036990119a99b7cd525add76651282ae1a @sstephenson committed May 18, 2011
Showing with 3 additions and 33 deletions.
  1. +0 −1 lib/sprockets/environment.rb
  2. +2 −8 lib/sprockets/processing.rb
  3. +1 −24 test/test_environment.rb
@@ -23,7 +23,6 @@ def initialize(root = ".")
@static_root = nil
- @mime_types = {}
@engines = {}
@formats = Hash.new { |h, k| h[k] = [] }
@filters = Hash.new { |h, k| h[k] = [] }
@@ -6,18 +6,12 @@ module Sprockets
module Processing
def mime_types(ext = nil)
if ext.nil?
- Rack::Mime::MIME_TYPES.merge(@mime_types)
+ Rack::Mime::MIME_TYPES.dup
else
- ext = normalize_extension(ext)
- @mime_types[ext] || Rack::Mime::MIME_TYPES[ext]
+ Rack::Mime::MIME_TYPES[ext]
end
end
- def register_mime_type(mime_type, ext)
- expire_index!
- @mime_types[normalize_extension(ext)] = mime_type
- end
-
def formats(ext = nil)
if ext
@formats[normalize_extension(ext)].dup
View
@@ -57,8 +57,7 @@ def self.test(name, &block)
test "lookup mime type" do
assert_equal "application/javascript", @env.mime_types(".js")
- assert_equal "application/javascript", @env.mime_types("js")
- assert_equal "text/css", @env.mime_types(:css)
+ assert_equal "text/css", @env.mime_types(".css")
assert_equal nil, @env.mime_types("foo")
assert_equal nil, @env.mime_types("foo")
end
@@ -269,12 +268,6 @@ def setup
@env = new_environment
end
- test "register mime type" do
- assert !@env.mime_types("jst")
- @env.register_mime_type("application/javascript", "jst")
- assert_equal "application/javascript", @env.mime_types("jst")
- end
-
test "register filter" do
assert !@env.filters('text/css').include?(WhitespaceCompressor)
@env.register_filter 'text/css', WhitespaceCompressor
@@ -428,22 +421,6 @@ def setup
end
end
- test "does not allow new mime types to be added" do
- assert_raises TypeError do
- @env.register_mime_type "application/javascript", ".jst"
- end
- end
-
- test "change in environment mime types does not affect index" do
- env = Sprockets::Environment.new(".")
- env.register_mime_type "application/javascript", ".jst"
- index = env.index
-
- assert_equal "application/javascript", index.mime_types("jst")
- env.register_mime_type nil, ".jst"
- assert_equal "application/javascript", index.mime_types("jst")
- end
-
test "does not allow new filters to be added" do
assert_raises TypeError do
@env.register_filter 'text/css', WhitespaceCompressor

0 comments on commit c246dc0

Please sign in to comment.