diff options
4 files changed, 9 insertions, 1 deletions
diff --git a/actionpack/lib/sprockets/helpers/rails_helper.rb b/actionpack/lib/sprockets/helpers/rails_helper.rb index 8ac137b4b5..37c37604d5 100644 --- a/actionpack/lib/sprockets/helpers/rails_helper.rb +++ b/actionpack/lib/sprockets/helpers/rails_helper.rb @@ -157,7 +157,9 @@ module Sprockets def rewrite_extension(source, dir, ext) source_ext = File.extname(source) if ext && source_ext != ".#{ext}" - if !source_ext.empty? && asset_environment[source] + asset = asset_environment[source] + if !source_ext.empty? && asset && + asset.pathname.to_s =~ /#{source}\Z/ source else "#{source}.#{ext}" diff --git a/actionpack/test/fixtures/sprockets/app/javascripts/foo.min.js b/actionpack/test/fixtures/sprockets/app/javascripts/foo.min.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/actionpack/test/fixtures/sprockets/app/javascripts/foo.min.js diff --git a/actionpack/test/fixtures/sprockets/app/stylesheets/style.min.css b/actionpack/test/fixtures/sprockets/app/stylesheets/style.min.css new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/actionpack/test/fixtures/sprockets/app/stylesheets/style.min.css diff --git a/actionpack/test/template/sprockets_helper_test.rb b/actionpack/test/template/sprockets_helper_test.rb index 65107b54b7..b908b6777c 100644 --- a/actionpack/test/template/sprockets_helper_test.rb +++ b/actionpack/test/template/sprockets_helper_test.rb @@ -257,6 +257,9 @@ class SprocketsHelperTest < ActionView::TestCase assert_match %r{\A<script src="/assets/xmlhr-[0-9a-f]+.js" type="text/javascript"></script>\Z}, javascript_include_tag("xmlhr", "xmlhr") + assert_match %r{\A<script src="/assets/foo.min-[0-9a-f]+.js" type="text/javascript"></script>\Z}, + javascript_include_tag("foo.min") + @config.assets.compile = true @config.assets.debug = true assert_match %r{<script src="/javascripts/application.js" type="text/javascript"></script>}, @@ -310,6 +313,9 @@ class SprocketsHelperTest < ActionView::TestCase assert_match %r{\A<link href="/assets/style-[0-9a-f]+.ext" media="screen" rel="stylesheet" type="text/css" />\Z}, stylesheet_link_tag("style.ext") + assert_match %r{\A<link href="/assets/style.min-[0-9a-f]+.css" media="screen" rel="stylesheet" type="text/css" />\Z}, + stylesheet_link_tag("style.min") + @config.assets.compile = true @config.assets.debug = true assert_match %r{<link href="/stylesheets/application.css" media="screen" rel="stylesheet" type="text/css" />}, |