Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #3192 from spohlenz/precompile-enhancement-fix

Fix regression in assets:precompile task when task is enhanced
  • Loading branch information...
commit 7e03ace6ab7fc55b1797ccb9d48c36a526099eca 2 parents 41cbd15 + a6614c5
@josevalim josevalim authored
View
2  actionpack/lib/sprockets/assets.rake
@@ -7,6 +7,7 @@ namespace :assets do
ENV["RAILS_GROUPS"] ||= "assets"
ENV["RAILS_ENV"] ||= "production"
ruby $0, *ARGV
+ exit
else
require "fileutils"
Rake::Task["tmp:cache:clear"].invoke
@@ -42,6 +43,7 @@ namespace :assets do
end
ENV["RAILS_ASSETS_NONDIGEST"] = "true"
ruby $0, *ARGV
+ exit
end
end
end
View
14 railties/test/application/assets_test.rb
@@ -22,7 +22,7 @@ def app
end
def precompile!
- capture(:stdout) do
+ quietly do
Dir.chdir(app_path){ `bundle exec rake assets:precompile` }
end
end
@@ -249,7 +249,7 @@ class ::PostsController < ActionController::Base ; end
# digest is default in false, we must enable it for test environment
add_to_config "config.assets.digest = true"
- capture(:stdout) do
+ quietly do
Dir.chdir(app_path){ `bundle exec rake assets:precompile RAILS_ENV=test` }
end
file = Dir["#{app_path}/public/assets/application.css"].first
@@ -281,7 +281,7 @@ class ::PostsController < ActionController::Base ; end
add_to_config "config.assets.compile = true"
ENV["RAILS_ENV"] = nil
- capture(:stdout) do
+ quietly do
Dir.chdir(app_path){ `bundle exec rake assets:precompile RAILS_GROUPS=assets` }
end
file = Dir["#{app_path}/public/assets/application-*.css"].first
@@ -306,7 +306,7 @@ class ::PostsController < ActionController::Base ; end
app_file "public/assets/application.css", "a { color: green; }"
app_file "public/assets/subdir/broken.png", "not really an image file"
- capture(:stdout) do
+ quietly do
Dir.chdir(app_path){ `bundle exec rake assets:clean` }
end
@@ -419,6 +419,12 @@ class ::PostsController < ActionController::Base ; end
assert_equal "NoPost;\n", File.read("#{app_path}/public/assets/application.js")
end
+ test "enhancements to assets:precompile should only run once" do
+ app_file "lib/tasks/enhance.rake", "Rake::Task['assets:precompile'].enhance { puts 'enhancement' }"
+ output = precompile!
+ assert_equal 1, output.scan("enhancement").size
+ end
+
private
def app_with_assets_in_view
Please sign in to comment.
Something went wrong with that request. Please try again.