1
0
Fork 0
mirror of https://github.com/heartcombo/devise.git synced 2022-11-09 12:18:31 -05:00

Merge pull request #3279 from Sinbadsoft/activesurppot_load_hooks

Add ActiveSupport load hook for DeviseController
This commit is contained in:
Lucas Mazza 2014-11-03 10:07:07 -02:00
commit 13e07b4b61
2 changed files with 21 additions and 0 deletions

View file

@ -180,4 +180,6 @@ MESSAGE
def resource_params def resource_params
params.fetch(resource_name, {}) params.fetch(resource_name, {})
end end
ActiveSupport.run_load_hooks(:devise_controller, self)
end end

View file

@ -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