mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
asset compilation should not require a database connection
This commit is contained in:
parent
e5248aacd0
commit
e5946e0396
1 changed files with 26 additions and 0 deletions
|
@ -83,6 +83,32 @@ module ApplicationTests
|
|||
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{}"
|
||||
|
|
Loading…
Reference in a new issue