Skip to content
This repository
Browse code

Merge pull request #6152 from route/assets_precompile_task_3_1

Just cherry-picked fixes for asset precompile for 3-1-stable
  • Loading branch information...
commit a33d9f435c6be4246661ae56a7e80c526e777c5f 2 parents 0cfa6b7 + 29aa03a
Jeremy Kemper authored May 04, 2012
3  actionpack/lib/sprockets/static_compiler.rb
@@ -16,6 +16,9 @@ def initialize(env, target, paths, options = {})
16 16
     def compile
17 17
       manifest = {}
18 18
       env.each_logical_path do |logical_path|
  19
+        if File.basename(logical_path)[/[^\.]+/, 0] == 'index'
  20
+          logical_path.sub!(/\/index\./, '.')
  21
+        end
19 22
         next unless compile_path?(logical_path)
20 23
         if asset = env.find_asset(logical_path)
21 24
           manifest[logical_path] = write_asset(asset)
9  railties/test/application/assets_test.rb
@@ -114,6 +114,15 @@ def precompile!
114 114
       assert !File.exists?("#{app_path}/public/assets/something.else.css")
115 115
     end
116 116
 
  117
+    test "precompile something.js for directory containing index file" do
  118
+      add_to_config "config.assets.precompile = [ 'something.js' ]"
  119
+      app_file "app/assets/javascripts/something/index.js.erb", "alert();"
  120
+
  121
+      precompile!
  122
+
  123
+      assert File.exists?("#{app_path}/public/assets/something.js")
  124
+    end
  125
+
117 126
     test "asset pipeline should use a Sprockets::Index when config.assets.digest is true" do
118 127
       add_to_config "config.assets.digest = true"
119 128
       add_to_config "config.action_controller.perform_caching = false"

0 notes on commit a33d9f4

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