diff options
Diffstat (limited to 'railties/test')
-rw-r--r-- | railties/test/application/assets_test.rb | 26 |
1 files changed, 19 insertions, 7 deletions
diff --git a/railties/test/application/assets_test.rb b/railties/test/application/assets_test.rb index 38dd3f5a3f..ccc03f8d9c 100644 --- a/railties/test/application/assets_test.rb +++ b/railties/test/application/assets_test.rb @@ -46,28 +46,40 @@ module ApplicationTests assert defined?(Uglifier) end - test "precompile creates the file and gives it the original asset's content" do + test "precompile creates the filem, gives it the original asset's content and run in production as default" do app_file "app/assets/javascripts/application.js", "alert();" app_file "app/assets/javascripts/foo/application.js", "alert();" + ENV["RAILS_ENV"] = nil capture(:stdout) do Dir.chdir(app_path){ `bundle exec rake assets:precompile` } end - files = Dir["#{app_path}/public/assets/application-*.js"] - files << Dir["#{app_path}/public/assets/foo/application-*.js"].first + files = Dir["#{app_path}/public/assets/application-b29a188b3d9c74ef7cbb7ddf9e99f953.js"] + files << Dir["#{app_path}/public/assets/foo/application-b29a188b3d9c74ef7cbb7ddf9e99f953.js"].first files.each do |file| assert_not_nil file, "Expected application.js asset to be generated, but none found" - assert_equal "alert();\n", File.read(file) + assert_equal "alert()", File.read(file) end end - test "precompile appends the md5 hash to files referenced with asset_path" do + test "precompile appends the md5 hash to files referenced with asset_path and run in the provided RAILS_ENV" do app_file "app/assets/stylesheets/application.css.erb", "<%= asset_path('rails.png') %>" + # capture(:stdout) do + Dir.chdir(app_path){ `bundle exec rake assets:precompile RAILS_ENV=test` } + # end + file = Dir["#{app_path}/public/assets/application-4bd8b7059c5336ec7ad515c9dbd59974.css"].first + assert_match /\/assets\/rails-([0-z]+)\.png/, File.read(file) + end + + test "precompile appends the md5 hash to files referenced with asset_path and run in production as default even using RAILS_GROUPS=assets" do + app_file "app/assets/stylesheets/application.css.erb", "<%= asset_path('rails.png') %>" + + ENV["RAILS_ENV"] = nil capture(:stdout) do - Dir.chdir(app_path){ `bundle exec rake assets:precompile` } + Dir.chdir(app_path){ `bundle exec rake assets:precompile RAILS_GROUPS=assets` } end - file = Dir["#{app_path}/public/assets/application-*.css"].first + file = Dir["#{app_path}/public/assets/application-8d301a938f1abfd789bbec87ed1ef770.css"].first assert_match /\/assets\/rails-([0-z]+)\.png/, File.read(file) end |