Permalink
Browse files

Merge pull request #3027 from alex3/assets-precompile-regex-fix

Default precompile regex was erroneously matching files
  • Loading branch information...
2 parents 676ddfc + 6e63e02 commit 2bf33bd4bcd488a35e641b32dd667f3092ea9197 @spastorino spastorino committed Sep 22, 2011
Showing with 10 additions and 1 deletion.
  1. +1 −1 railties/lib/rails/application/configuration.rb
  2. +9 −0 railties/test/application/assets_test.rb
View
2 railties/lib/rails/application/configuration.rb
@@ -38,7 +38,7 @@ def initialize(*)
@assets.enabled = false
@assets.paths = []
@assets.precompile = [ Proc.new{ |path| !File.extname(path).in?(['.js', '.css']) },
- /application.(css|js)$/ ]
+ /(?:\/|\\|\A)application\.(css|js)$/ ]
@assets.prefix = "/assets"
@assets.version = ''
@assets.debug = false
View
9 railties/test/application/assets_test.rb
@@ -68,6 +68,10 @@ def app
test "precompile application.js and application.css and all other files not ending with .js or .css by default" do
app_file "app/assets/javascripts/application.js", "alert();"
app_file "app/assets/stylesheets/application.css", "body{}"
+
+ app_file "app/assets/javascripts/someapplication.js", "alert();"
+ app_file "app/assets/stylesheets/someapplication.css", "body{}"
+
app_file "app/assets/javascripts/something.min.js", "alert();"
app_file "app/assets/stylesheets/something.min.css", "body{}"
@@ -87,8 +91,13 @@ def app
images_should_compile.each do |filename|
assert File.exists?("#{app_path}/public/assets/#{filename}")
end
+
assert File.exists?("#{app_path}/public/assets/application.js")
assert File.exists?("#{app_path}/public/assets/application.css")
+
+ assert !File.exists?("#{app_path}/public/assets/someapplication.js")
+ assert !File.exists?("#{app_path}/public/assets/someapplication.css")
+
assert !File.exists?("#{app_path}/public/assets/something.min.js")
assert !File.exists?("#{app_path}/public/assets/something.min.css")
end

0 comments on commit 2bf33bd

Please sign in to comment.