Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

asset compilation should not require a database connection

  • Loading branch information...
commit e5946e0396eaa581391a93026ebe816a3bf4409d 1 parent e5248aa
@tenderlove tenderlove authored
Showing with 26 additions and 0 deletions.
  1. +26 −0 railties/test/application/assets_test.rb
View
26 railties/test/application/assets_test.rb
@@ -83,6 +83,32 @@ def assert_no_file_exists(filename)
end
end
+ def test_precompile_does_not_hit_the_database
+ app_file "app/assets/javascripts/application.js", "alert();"
+ app_file "app/assets/javascripts/foo/application.js", "alert();"
+ app_file "app/controllers/user_controller.rb", <<-eoruby
+ class UserController < ApplicationController; end
+ eoruby
+ app_file "app/models/user.rb", <<-eoruby
+ class User < ActiveRecord::Base; end
+ eoruby
+
+ ENV['RAILS_ENV'] = 'production'
+ ENV['DATABASE_URL'] = 'postgresql://baduser:badpass@127.0.0.1/dbname'
+
+ precompile!
+
+ files = Dir["#{app_path}/public/assets/application-*.js"]
+ files << Dir["#{app_path}/public/assets/foo/application-*.js"].first
+ files.each do |file|
+ assert_not_nil file, "Expected application.js asset to be generated, but none found"
+ assert_equal "alert();".strip, File.read(file).strip
+ end
+ ensure
+ ENV.delete 'RAILS_ENV'
+ ENV.delete 'DATABASE_URL'
+ end
+
test "precompile application.js and application.css and all other non JS/CSS files" do
app_file "app/assets/javascripts/application.js", "alert();"
app_file "app/assets/stylesheets/application.css", "body{}"

1 comment on commit e5946e0

@schneems
Collaborator

:heart: thanks for this.

Please sign in to comment.
Something went wrong with that request. Please try again.