mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Fixed assets precompile regex, now accepts Procs
This commit is contained in:
parent
e05d4cea69
commit
901c02d86a
3 changed files with 32 additions and 1 deletions
|
@ -26,6 +26,8 @@ namespace :assets do
|
||||||
env.each_logical_path do |logical_path|
|
env.each_logical_path do |logical_path|
|
||||||
if path.is_a?(Regexp)
|
if path.is_a?(Regexp)
|
||||||
next unless path.match(logical_path)
|
next unless path.match(logical_path)
|
||||||
|
elsif path.is_a?(Proc)
|
||||||
|
next unless path.call(logical_path)
|
||||||
else
|
else
|
||||||
next unless File.fnmatch(path.to_s, logical_path)
|
next unless File.fnmatch(path.to_s, logical_path)
|
||||||
end
|
end
|
||||||
|
|
|
@ -37,7 +37,8 @@ module Rails
|
||||||
@assets = ActiveSupport::OrderedOptions.new
|
@assets = ActiveSupport::OrderedOptions.new
|
||||||
@assets.enabled = false
|
@assets.enabled = false
|
||||||
@assets.paths = []
|
@assets.paths = []
|
||||||
@assets.precompile = [ /\w+\.(?!js|css).+/, /application.(css|js)$/ ]
|
@assets.precompile = [ Proc.new{ |path| !File.extname(path).in?(['.js', '.css']) },
|
||||||
|
/application.(css|js)$/ ]
|
||||||
@assets.prefix = "/assets"
|
@assets.prefix = "/assets"
|
||||||
@assets.version = ''
|
@assets.version = ''
|
||||||
@assets.debug = false
|
@assets.debug = false
|
||||||
|
|
|
@ -64,6 +64,34 @@ module ApplicationTests
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
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/something.min.js", "alert();"
|
||||||
|
app_file "app/assets/stylesheets/something.min.css", "body{}"
|
||||||
|
|
||||||
|
images_should_compile = ["a.png", "happyface.png", "happy_face.png", "happy.face.png",
|
||||||
|
"happy-face.png", "happy.happy_face.png", "happy_happy.face.png",
|
||||||
|
"happy.happy.face.png", "happy", "happy.face", "-happyface",
|
||||||
|
"-happy.png", "-happy.face.png", "_happyface", "_happy.face.png",
|
||||||
|
"_happy.png"]
|
||||||
|
images_should_compile.each do |filename|
|
||||||
|
app_file "app/assets/images/#{filename}", "happy"
|
||||||
|
end
|
||||||
|
|
||||||
|
capture(:stdout) do
|
||||||
|
Dir.chdir(app_path){ `bundle exec rake assets:precompile` }
|
||||||
|
end
|
||||||
|
|
||||||
|
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/something.min.js")
|
||||||
|
assert !File.exists?("#{app_path}/public/assets/something.min.css")
|
||||||
|
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"
|
||||||
|
|
Loading…
Reference in a new issue