diff options
author | James A. Rosen <james@zendesk.com> | 2011-06-21 09:35:48 -0700 |
---|---|---|
committer | James A. Rosen <james@zendesk.com> | 2011-06-21 09:51:18 -0700 |
commit | 7ca14ea39854407968a9264905a1965381a27c2a (patch) | |
tree | fefb04e678723bae89482456fee477c402cc35b3 | |
parent | d26cf14605c02495263b3f5edd390569bfead11c (diff) | |
download | rails-7ca14ea39854407968a9264905a1965381a27c2a.tar.gz rails-7ca14ea39854407968a9264905a1965381a27c2a.tar.bz2 rails-7ca14ea39854407968a9264905a1965381a27c2a.zip |
Railties: added tests for rake assets:clean
-rw-r--r-- | railties/lib/rails/tasks/assets.rake | 4 | ||||
-rw-r--r-- | railties/test/application/assets_test.rb | 14 |
2 files changed, 16 insertions, 2 deletions
diff --git a/railties/lib/rails/tasks/assets.rake b/railties/lib/rails/tasks/assets.rake index 2d3a9dea96..0236350576 100644 --- a/railties/lib/rails/tasks/assets.rake +++ b/railties/lib/rails/tasks/assets.rake @@ -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, :force => true - rm "#{file}.gz", :force => true + rm_rf file + rm_rf "#{file}.gz" end end end diff --git a/railties/test/application/assets_test.rb b/railties/test/application/assets_test.rb index a93786becd..b76dae8e18 100644 --- a/railties/test/application/assets_test.rb +++ b/railties/test/application/assets_test.rb @@ -43,9 +43,23 @@ module ApplicationTests 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 %>();" |