Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Do not add files in assets/ directories to Sprockets

  • Loading branch information...
commit b4ca7d3c3df3acc830df2e546303bc7416b5c878 1 parent b2eaf96
Tasveer Singh tazsingh authored
6 railties/lib/rails/engine.rb
View
@@ -538,9 +538,9 @@ def load_seed
end
initializer :append_assets_path do |app|
- app.config.assets.paths.unshift(*paths["vendor/assets"].existent)
- app.config.assets.paths.unshift(*paths["lib/assets"].existent)
- app.config.assets.paths.unshift(*paths["app/assets"].existent)
+ app.config.assets.paths.unshift(*paths["vendor/assets"].existent_directories)
+ app.config.assets.paths.unshift(*paths["lib/assets"].existent_directories)
+ app.config.assets.paths.unshift(*paths["app/assets"].existent_directories)
end
initializer :prepend_helpers_path do |app|
4 railties/lib/rails/paths.rb
View
@@ -193,6 +193,10 @@ def expanded
def existent
expanded.select { |f| File.exists?(f) }
end
+
+ def existent_directories
+ expanded.select {|d| Dir.exists?(d) }
+ end
def paths
ActiveSupport::Deprecation.warn "paths is deprecated. Please call expand instead."
14 railties/test/application/assets_test.rb
View
@@ -86,5 +86,19 @@ def index
assert_match "alert()", last_response.body
assert_equal nil, last_response.headers["Set-Cookie"]
end
+
+ test "files in any assets/ directories are not added to Sprockets" do
+ %w[app lib vendor].each do |dir|
+ app_file "#{dir}/assets/#{dir}_test.erb", "testing"
+ end
+
+ app_file "app/assets/javascripts/demo.js", "alert();"
+
+ require "#{app_path}/config/environment"
+
+ get "/assets/demo.js"
+ assert_match "alert();", last_response.body
+ assert_equal 200, last_response.status
+ end
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.