File tree Expand file tree Collapse file tree 2 files changed +30
-0
lines changed
Expand file tree Collapse file tree 2 files changed +30
-0
lines changed Original file line number Diff line number Diff line change @@ -124,6 +124,11 @@ def preload
124124
125125 if defined? ( Rails ) && Rails . application
126126 watcher . add Rails . application . paths [ "config/initializers" ]
127+ Rails ::Engine . descendants . each do |engine |
128+ if engine . root . to_s . start_with? ( Rails . root . to_s )
129+ watcher . add engine . paths [ "config/initializers" ] . expanded
130+ end
131+ end
127132 watcher . add Rails . application . paths [ "config/database" ]
128133 if secrets_path = Rails . application . paths [ "config/secrets" ]
129134 watcher . add secrets_path
Original file line number Diff line number Diff line change @@ -715,6 +715,31 @@ def exec_name
715715 test "rails db:system:change" do
716716 assert_success "bin/rails db:system:change --to=sqlite3"
717717 end
718+
719+ test "watches embedded engine initializers" do
720+ app . path ( "config/application.rb" ) . write ( <<~RUBY , mode : "a+" )
721+
722+ $LOAD_PATH << Pathname.new(__dir__).join("../engine/lib").realpath.to_s
723+ require "my_engine"
724+ RUBY
725+ engine_lib = app . path ( "engine/lib/my_engine.rb" )
726+ engine_lib . dirname . mkpath
727+ engine_lib . write ( <<~RUBY )
728+ require "rails/engine"
729+
730+ class MyEngine < Rails::Engine
731+ end
732+ RUBY
733+ engine_initializer = app . path ( "engine/config/initializers/one.rb" )
734+ engine_initializer . dirname . mkpath
735+ engine_initializer . write ( "" )
736+
737+ assert_success app . spring_test_command
738+
739+ engine_initializer . write ( "raise 'omg'" )
740+
741+ assert_failure app . spring_test_command , stderr : "omg (RuntimeError)"
742+ end
718743 end
719744 end
720745end
You can’t perform that action at this time.
0 commit comments