diff options
author | Jeremy Weathers <jeremy@codekindly.com> | 2019-04-02 16:21:57 -0500 |
---|---|---|
committer | Jeremy Weathers <jeremy@codekindly.com> | 2019-04-19 10:57:42 -0500 |
commit | b08daf48dac4e98076a6eaad5cddc8405ec91af9 (patch) | |
tree | 93a30ee15925bcbd83abe90e4ce9ba6175e8807a /railties/test | |
parent | 1a5381ff0cf04af68a50bd04f265b9b8199e37b4 (diff) | |
download | rails-b08daf48dac4e98076a6eaad5cddc8405ec91af9.tar.gz rails-b08daf48dac4e98076a6eaad5cddc8405ec91af9.tar.bz2 rails-b08daf48dac4e98076a6eaad5cddc8405ec91af9.zip |
[#35782] Allow loading seeds without ActiveJob (~> 5.2.3)
Diffstat (limited to 'railties/test')
-rw-r--r-- | railties/test/railties/engine_test.rb | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/railties/test/railties/engine_test.rb b/railties/test/railties/engine_test.rb index fe5c62c07d..8ce68dbcfa 100644 --- a/railties/test/railties/engine_test.rb +++ b/railties/test/railties/engine_test.rb @@ -904,6 +904,32 @@ YAML assert_instance_of ActiveJob::QueueAdapters::DelayedJobAdapter, ActiveJob::Base.queue_adapter end + test "seed data can be loaded when ActiveJob is not present" do + @plugin.write "db/seeds.rb", <<-RUBY + Bukkits::Engine.config.bukkits_seeds_loaded = true + RUBY + + app_file "db/seeds.rb", <<-RUBY + Rails.application.config.app_seeds_loaded = true + RUBY + + boot_rails + + # In a real app, config.active_job would be undefined when + # NOT requiring rails/all AND NOT requiring active_job/railtie + # that doesn't work as expected in this test environment, so: + undefine_config_option(:active_job) + assert_raise(NoMethodError) { Rails.application.config.active_job } + + assert_raise(NoMethodError) { Rails.application.config.app_seeds_loaded } + assert_raise(NoMethodError) { Bukkits::Engine.config.bukkits_seeds_loaded } + + Rails.application.load_seed + assert Rails.application.config.app_seeds_loaded + Bukkits::Engine.load_seed + assert Bukkits::Engine.config.bukkits_seeds_loaded + end + test "skips nonexistent seed data" do FileUtils.rm "#{app_path}/db/seeds.rb" boot_rails @@ -1523,6 +1549,10 @@ YAML Rails.application end + def undefine_config_option(name) + Rails.application.config.class.class_variable_get(:@@options).delete(name) + end + # Restrict frameworks to load in order to avoid engine frameworks affect tests. def restrict_frameworks remove_from_config("require 'rails/all'") |