aboutsummaryrefslogtreecommitdiffstats
path: root/railties/lib/rails
diff options
context:
space:
mode:
authorRafael França <rafaelmfranca@gmail.com>2019-01-17 11:06:41 -0500
committerGitHub <noreply@github.com>2019-01-17 11:06:41 -0500
commit2dee59fed1e78b983aed4db53dc8fc59e49b9200 (patch)
treedb51feed99ce401fac39c463e19f9c8133b7bcb2 /railties/lib/rails
parent05350eda9b3f6689374a20711c946f530a8bbd6d (diff)
parent66cc0e768fb092dbcd12feb3387c2a22e4cbeb37 (diff)
downloadrails-2dee59fed1e78b983aed4db53dc8fc59e49b9200.tar.gz
rails-2dee59fed1e78b983aed4db53dc8fc59e49b9200.tar.bz2
rails-2dee59fed1e78b983aed4db53dc8fc59e49b9200.zip
Merge pull request #34953 from gmcgibbon/seed_with_inline_jobs
Seed database with inline ActiveJob job adapter
Diffstat (limited to 'railties/lib/rails')
-rw-r--r--railties/lib/rails/engine.rb14
1 files changed, 13 insertions, 1 deletions
diff --git a/railties/lib/rails/engine.rb b/railties/lib/rails/engine.rb
index 6a13a84108..f768c30db0 100644
--- a/railties/lib/rails/engine.rb
+++ b/railties/lib/rails/engine.rb
@@ -548,7 +548,7 @@ module Rails
# Blog::Engine.load_seed
def load_seed
seed_file = paths["db/seeds.rb"].existent.first
- load(seed_file) if seed_file
+ with_inline_jobs { load(seed_file) } if seed_file
end
# Add configured load paths to Ruby's load path, and remove duplicate entries.
@@ -658,6 +658,18 @@ module Rails
end
end
+ def with_inline_jobs
+ queue_adapter = config.active_job.queue_adapter
+ ActiveSupport.on_load(:active_job) do
+ self.queue_adapter = :inline
+ end
+ yield
+ ensure
+ ActiveSupport.on_load(:active_job) do
+ self.queue_adapter = queue_adapter
+ end
+ end
+
def has_migrations?
paths["db/migrate"].existent.any?
end