Skip to content
Browse files

Format extension cant be an engine

  • Loading branch information...
1 parent 559b49a commit e6160f0d23030ceb47c90f66a78a7e5f2e30b0a6 @josh josh committed Jul 8, 2011
Showing with 15 additions and 8 deletions.
  1. +3 −1 lib/sprockets/asset_attributes.rb
  2. +12 −7 test/test_asset_attributes.rb
View
4 lib/sprockets/asset_attributes.rb
@@ -59,7 +59,9 @@ def extensions
# # => ".js"
#
def format_extension
- extensions.detect { |ext| @environment.mime_types(ext) }
+ extensions.detect { |ext|
+ @environment.mime_types(ext) && !@environment.engines(ext)
+ }
end
# Returns an `Array` of engine extensions.
View
19 test/test_asset_attributes.rb
@@ -54,24 +54,29 @@ class TestAssetAttributes < Sprockets::TestCase
assert_equal ".js", pathname("jquery.min.js").format_extension
assert_equal ".js", pathname("jquery.tmpl.js").format_extension
assert_equal ".js", pathname("jquery.tmpl.min.js").format_extension
+
+ env = Sprockets::Environment.new
+ env.register_engine '.ms', Class.new
+ assert_equal nil, env.attributes_for("foo.jst.ms").format_extension
end
- test "engine_extensions" do
+ test "engine extensions" do
assert_equal [], pathname("empty").engine_extensions
assert_equal [], pathname("gallery.js").engine_extensions
- assert_equal [".coffee"],
- pathname("application.js.coffee").engine_extensions
- assert_equal [".coffee", ".erb"],
- pathname("project.js.coffee.erb").engine_extensions
+ assert_equal [".coffee"], pathname("application.js.coffee").engine_extensions
+ assert_equal [".coffee", ".erb"], pathname("project.js.coffee.erb").engine_extensions
assert_equal [".erb"], pathname("gallery.css.erb").engine_extensions
assert_equal [".erb"], pathname("gallery.erb").engine_extensions
assert_equal [], pathname("jquery.js").engine_extensions
assert_equal [], pathname("jquery.min.js").engine_extensions
assert_equal [], pathname("jquery.tmpl.min.js").engine_extensions
assert_equal [".erb"], pathname("jquery.js.erb").engine_extensions
assert_equal [".erb"], pathname("jquery.min.js.erb").engine_extensions
- assert_equal [".coffee"],
- pathname("jquery.min.coffee").engine_extensions
+ assert_equal [".coffee"], pathname("jquery.min.coffee").engine_extensions
+
+ env = Sprockets::Environment.new
+ env.register_engine '.ms', Class.new
+ assert_equal [".jst", ".ms"], env.attributes_for("foo.jst.ms").engine_extensions
end
test "content_type" do

0 comments on commit e6160f0

Please sign in to comment.
Something went wrong with that request. Please try again.