Fixed assets loading performance in 3.2.13

The PR #8756 uses Sprockets for resolving files that already exists on disk, for those files their extensions don't need to be rewritten.

Fixes #9803
This commit is contained in:
Fred Wu
2013-03-20 16:13:30 +11:00
parent 517060ab59
commit 687e68d88f
2 changed files with 10 additions and 1 deletions

View File

@@ -163,7 +163,7 @@ module Sprockets
source
elsif source_ext.blank?
"#{source}.#{ext}"
elsif exact_match_present?(source)
elsif File.exists?(source) || exact_match_present?(source)
source
else
"#{source}.#{ext}"

View File

@@ -277,6 +277,15 @@ class SprocketsHelperTest < ActionView::TestCase
assert_nothing_raised { javascript_include_tag('foo.min') }
end
test "assets that exist on filesystem don't need to go through Sprockets" do
@config.assets.digest = false
@config.assets.debug = true
Rails.application.assets.expects(:resolve).never
asset_paths.asset_for(FIXTURES.join("sprockets/app/javascripts/foo.min.js").to_path, 'min')
end
test "stylesheet path through asset_path" do
assert_match %r{/assets/application-[0-9a-f]+.css}, asset_path(:application, :ext => "css")