Skip to content

Commit

Permalink
Merge pull request #6152 from route/assets_precompile_task_3_1
Browse files Browse the repository at this point in the history
Just cherry-picked fixes for asset precompile for 3-1-stable
  • Loading branch information
jeremy committed May 4, 2012
2 parents 0cfa6b7 + 29aa03a commit a33d9f4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
3 changes: 3 additions & 0 deletions actionpack/lib/sprockets/static_compiler.rb
Expand Up @@ -16,6 +16,9 @@ def initialize(env, target, paths, options = {})
def compile def compile
manifest = {} manifest = {}
env.each_logical_path do |logical_path| env.each_logical_path do |logical_path|
if File.basename(logical_path)[/[^\.]+/, 0] == 'index'
logical_path.sub!(/\/index\./, '.')
end
next unless compile_path?(logical_path) next unless compile_path?(logical_path)
if asset = env.find_asset(logical_path) if asset = env.find_asset(logical_path)
manifest[logical_path] = write_asset(asset) manifest[logical_path] = write_asset(asset)
Expand Down
9 changes: 9 additions & 0 deletions railties/test/application/assets_test.rb
Expand Up @@ -114,6 +114,15 @@ def precompile!
assert !File.exists?("#{app_path}/public/assets/something.else.css") assert !File.exists?("#{app_path}/public/assets/something.else.css")
end end


test "precompile something.js for directory containing index file" do
add_to_config "config.assets.precompile = [ 'something.js' ]"
app_file "app/assets/javascripts/something/index.js.erb", "alert();"

precompile!

assert File.exists?("#{app_path}/public/assets/something.js")
end

test "asset pipeline should use a Sprockets::Index when config.assets.digest is true" do test "asset pipeline should use a Sprockets::Index when config.assets.digest is true" do
add_to_config "config.assets.digest = true" add_to_config "config.assets.digest = true"
add_to_config "config.action_controller.perform_caching = false" add_to_config "config.action_controller.perform_caching = false"
Expand Down

0 comments on commit a33d9f4

Please sign in to comment.