File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -269,10 +269,16 @@ def default_hidden_fields=(fields)
269269
270270 def parent_controller = ( name )
271271 @parent_controller = name
272+
272273 if defined? ( RailsAdmin ::ApplicationController )
273274 RailsAdmin . send ( :remove_const , :ApplicationController )
274275 load RailsAdmin ::Engine . root . join ( 'app/controllers/rails_admin/application_controller.rb' )
275276 end
277+
278+ if defined? ( RailsAdmin ::MainController )
279+ RailsAdmin . send ( :remove_const , :MainController )
280+ load RailsAdmin ::Engine . root . join ( 'app/controllers/rails_admin/main_controller.rb' )
281+ end
276282 end
277283
278284 def total_columns_width = ( _ )
Original file line number Diff line number Diff line change @@ -283,6 +283,11 @@ class TestController < ActionController::Base; end
283283
284284 describe '.parent_controller=' do
285285 context 'if RailsAdmin::ApplicationController is already loaded' do
286+ before do
287+ # preload cotrollers (e.g. when config.eager_load = true)
288+ RailsAdmin ::MainController
289+ end
290+
286291 after do
287292 RailsAdmin ::Config . reset
288293 RailsAdmin . send ( :remove_const , :ApplicationController )
@@ -292,6 +297,7 @@ class TestController < ActionController::Base; end
292297 it 'can be changed' do
293298 RailsAdmin . config . parent_controller = 'ApplicationController'
294299 expect ( RailsAdmin ::ApplicationController . superclass ) . to eq ApplicationController
300+ expect ( RailsAdmin ::MainController . superclass . superclass ) . to eq ApplicationController
295301 end
296302 end
297303 end
You can’t perform that action at this time.
0 commit comments