File tree Expand file tree Collapse file tree 3 files changed +25
-2
lines changed Expand file tree Collapse file tree 3 files changed +25
-2
lines changed Original file line number Diff line number Diff line change
1
+ * Only force ` :async ` ActiveJob adapter to ` :inline ` during seeding.
2
+
3
+ * BatedUrGonnaDie*
4
+
1
5
* The ` connection ` option of ` rails dbconsole ` command is deprecated in
2
6
favor of ` database ` option.
3
7
Original file line number Diff line number Diff line change @@ -550,7 +550,13 @@ def config
550
550
# Blog::Engine.load_seed
551
551
def load_seed
552
552
seed_file = paths [ "db/seeds.rb" ] . existent . first
553
- with_inline_jobs { load ( seed_file ) } if seed_file
553
+ return unless seed_file
554
+
555
+ if config . active_job . queue_adapter == :async
556
+ with_inline_jobs { load ( seed_file ) }
557
+ else
558
+ load ( seed_file )
559
+ end
554
560
end
555
561
556
562
# Add configured load paths to Ruby's load path, and remove duplicate entries.
Original file line number Diff line number Diff line change @@ -879,7 +879,7 @@ def index
879
879
assert Bukkits ::Engine . config . bukkits_seeds_loaded
880
880
end
881
881
882
- test "jobs are ran inline while loading seeds" do
882
+ test "jobs are ran inline while loading seeds with async adapter configured " do
883
883
app_file "db/seeds.rb" , <<-RUBY
884
884
Rails.application.config.seed_queue_adapter = ActiveJob::Base.queue_adapter
885
885
RUBY
@@ -891,6 +891,19 @@ def index
891
891
assert_instance_of ActiveJob ::QueueAdapters ::AsyncAdapter , ActiveJob ::Base . queue_adapter
892
892
end
893
893
894
+ test "jobs are ran with original adapter while loading seeds with custom adapter configured" do
895
+ app_file "db/seeds.rb" , <<-RUBY
896
+ Rails.application.config.seed_queue_adapter = ActiveJob::Base.queue_adapter
897
+ RUBY
898
+
899
+ boot_rails
900
+ Rails . application . config . active_job . queue_adapter = :delayed_job
901
+ Rails . application . load_seed
902
+
903
+ assert_instance_of ActiveJob ::QueueAdapters ::DelayedJobAdapter , Rails . application . config . seed_queue_adapter
904
+ assert_instance_of ActiveJob ::QueueAdapters ::DelayedJobAdapter , ActiveJob ::Base . queue_adapter
905
+ end
906
+
894
907
test "skips nonexistent seed data" do
895
908
FileUtils . rm "#{ app_path } /db/seeds.rb"
896
909
boot_rails
You can’t perform that action at this time.
0 commit comments