diff options
author | yuuji.yaginuma <yuuji.yaginuma@gmail.com> | 2019-01-18 15:07:05 +0900 |
---|---|---|
committer | yuuji.yaginuma <yuuji.yaginuma@gmail.com> | 2019-02-06 11:11:43 +0900 |
commit | 6adc3da727a8b658784fad9d92927f8a53236793 (patch) | |
tree | 8cb6aad7c530193d1470533738892cc72e34b1e2 /railties | |
parent | 3127f5783ef3f07a05476b4a036d069d96def603 (diff) | |
download | rails-6adc3da727a8b658784fad9d92927f8a53236793.tar.gz rails-6adc3da727a8b658784fad9d92927f8a53236793.tar.bz2 rails-6adc3da727a8b658784fad9d92927f8a53236793.zip |
Restrict frameworks to load in engine test
For avoid to affect tests. Also, `action_text:install` task execute
`yarn add`. This is an expensive and should be avoided if it is not needed.
Diffstat (limited to 'railties')
-rw-r--r-- | railties/test/railties/engine_test.rb | 26 |
1 files changed, 22 insertions, 4 deletions
diff --git a/railties/test/railties/engine_test.rb b/railties/test/railties/engine_test.rb index 508367212b..851407dede 100644 --- a/railties/test/railties/engine_test.rb +++ b/railties/test/railties/engine_test.rb @@ -87,11 +87,10 @@ module RailtiesTest end RUBY + restrict_frameworks boot_rails Dir.chdir(app_path) do - # Install Active Storage, Action Mailbox, and Action Text migration files first so as not to affect test. - `bundle exec rake active_storage:install action_mailbox:install action_text:install` output = `bundle exec rake bukkits:install:migrations` ["CreateUsers", "AddLastNameToUsers", "CreateSessions"].each do |migration_name| @@ -174,11 +173,10 @@ module RailtiesTest class CreateKeys < ActiveRecord::Migration::Current; end RUBY + restrict_frameworks boot_rails Dir.chdir(app_path) do - # Install Active Storage, Action Mailbox, and Action Text migrations first so as not to affect test. - `bundle exec rake active_storage:install action_mailbox:install action_text:install` output = `bundle exec rake railties:install:migrations`.split("\n") assert_match(/Copied migration \d+_create_users\.core_engine\.rb from core_engine/, output.first) @@ -1509,5 +1507,25 @@ YAML def app Rails.application end + + # Restrict frameworks to load in order to avoid engine frameworks affect tests. + def restrict_frameworks + remove_from_config("require 'rails/all'") + remove_from_config("require_relative 'boot'") + remove_from_env_config("development", "config.active_storage.*") + frameworks = <<~RUBY + require "rails" + require "active_model/railtie" + require "active_job/railtie" + require "active_record/railtie" + require "action_controller/railtie" + require "action_mailer/railtie" + require "action_view/railtie" + require "sprockets/railtie" + require "rails/test_unit/railtie" + RUBY + environment = File.read("#{app_path}/config/application.rb") + File.open("#{app_path}/config/application.rb", "w") { |f| f.puts frameworks + "\n" + environment } + end end end |