diff options
author | yuuji.yaginuma <yuuji.yaginuma@gmail.com> | 2019-03-08 11:33:00 +0900 |
---|---|---|
committer | yuuji.yaginuma <yuuji.yaginuma@gmail.com> | 2019-03-08 11:44:22 +0900 |
commit | a942e3128042b8796348909a0a23527340e1d2cb (patch) | |
tree | de8ed8666e15e19927a77b182a8107a2c33440c9 /railties/test/isolation | |
parent | a62683f3e4326b222b6ad95b8b2dfcc31026d227 (diff) | |
download | rails-a942e3128042b8796348909a0a23527340e1d2cb.tar.gz rails-a942e3128042b8796348909a0a23527340e1d2cb.tar.bz2 rails-a942e3128042b8796348909a0a23527340e1d2cb.zip |
Build assets automatically if necessary
In CI, these are unnecessary because done by preprocessing.
To test locally, you need to do it manually. If assets not exist, it will
fail when a run specific test, so force to build those only when necessary.
Diffstat (limited to 'railties/test/isolation')
-rw-r--r-- | railties/test/isolation/abstract_unit.rb | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/railties/test/isolation/abstract_unit.rb b/railties/test/isolation/abstract_unit.rb index 3f1638a516..b0662e0159 100644 --- a/railties/test/isolation/abstract_unit.rb +++ b/railties/test/isolation/abstract_unit.rb @@ -488,7 +488,14 @@ Module.new do f.puts "require 'rails/all'" end + unless File.exist?("#{RAILS_FRAMEWORK_ROOT}/actionview/lib/assets/compiled/rails-ujs.js") + Dir.chdir("#{RAILS_FRAMEWORK_ROOT}/actionview") { `yarn build` } + end + assets_path = "#{RAILS_FRAMEWORK_ROOT}/railties/test/isolation/assets" + unless Dir.exist?("#{assets_path}/node_modules") + Dir.chdir(assets_path) { `yarn install` } + end FileUtils.cp("#{assets_path}/package.json", "#{app_template_path}/package.json") FileUtils.cp("#{assets_path}/config/webpacker.yml", "#{app_template_path}/config/webpacker.yml") FileUtils.cp_r("#{assets_path}/config/webpack", "#{app_template_path}/config/webpack") |