Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #1793 from jamesarosen/clean_images

rake assets:clean also removes directories
  • Loading branch information...
commit e369682ef1c405cab5cfa2f4066b7a0ca74a71fc 2 parents 458512c + 7ca14ea
José Valim josevalim authored
4 railties/lib/rails/tasks/assets.rake
View
@@ -19,8 +19,8 @@ namespace :assets do
public_asset_path = Rails.public_path + assets.prefix
file_list = FileList.new("#{public_asset_path}/**/*")
file_list.each do |file|
- rm file
- rm "#{file}.gz", :force => true
+ rm_rf file
+ rm_rf "#{file}.gz"
end
end
end
14 railties/test/application/assets_test.rb
View
@@ -43,9 +43,23 @@ def app
end
file = Dir["#{app_path}/public/assets/application-*.js"][0]
+ assert_not_nil file, "Expected application.js asset to be generated, but none found"
assert_equal "alert();\n", File.read(file)
end
+ test "assets are cleaned up properly" do
+ app_file "public/assets/application.js", "alert();"
+ app_file "public/assets/application.css", "a { color: green; }"
+ app_file "public/assets/subdir/broken.png", "not really an image file"
+
+ capture(:stdout) do
+ Dir.chdir(app_path){ `bundle exec rake assets:clean` }
+ end
+
+ files = Dir["#{app_path}/public/assets/**/*"]
+ assert_equal 0, files.length, "Expected no assets, but found #{files.join(', ')}"
+ end
+
test "does not stream session cookies back" do
app_file "app/assets/javascripts/demo.js.erb", "<%= :alert %>();"
Please sign in to comment.
Something went wrong with that request. Please try again.