diff --git a/app/controllers/devise_controller.rb b/app/controllers/devise_controller.rb index 20cc161f..722170ca 100644 --- a/app/controllers/devise_controller.rb +++ b/app/controllers/devise_controller.rb @@ -180,4 +180,6 @@ MESSAGE def resource_params params.fetch(resource_name, {}) end + + ActiveSupport.run_load_hooks(:devise_controller, self) end diff --git a/test/controllers/load_hooks_controller_test.rb b/test/controllers/load_hooks_controller_test.rb new file mode 100644 index 00000000..4f6d9a8e --- /dev/null +++ b/test/controllers/load_hooks_controller_test.rb @@ -0,0 +1,19 @@ +require 'test_helper' + +class LoadHooksControllerTest < ActionController::TestCase + setup do + ActiveSupport.on_load(:devise_controller) do + define_method :defined_by_load_hook do + puts 'I am defined dynamically by activesupport load hook' + end + end + end + + teardown do + DeviseController.class_eval { undef :defined_by_load_hook } + end + + test 'load hook called when controller is loaded' do + assert DeviseController.instance_methods.include? :defined_by_load_hook + end +end \ No newline at end of file