From 0510208dd1ff23baa619884c0abcae4d141fae53 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafael=20Mendon=C3=A7a=20Fran=C3=A7a?= Date: Thu, 25 Aug 2016 04:22:48 -0300 Subject: Add load hooks to all tests classes Usually users extends tests classes doing something like: ActionView::TestCase.include MyCustomTestHelpers This is bad because it will load the ActionView::TestCase right aways and this will load ActionController::Base making its on_load hooks to execute early than it should. One way to fix this is using the on_load hooks of the components like: ActiveSupport.on_load(:action_view) do ActionView::TestCase.include MyCustomTestHelpers end The problem with this approach is that the test extension will be only load when ActionView::Base is loaded and this may happen too late in the test. To fix this we are adding hooks to people extend the test classes that will be loaded exactly when the test classes are needed. --- actionview/lib/action_view/test_case.rb | 1 + 1 file changed, 1 insertion(+) (limited to 'actionview/lib/action_view/test_case.rb') diff --git a/actionview/lib/action_view/test_case.rb b/actionview/lib/action_view/test_case.rb index 2805cfe612..3eb1ac0826 100644 --- a/actionview/lib/action_view/test_case.rb +++ b/actionview/lib/action_view/test_case.rb @@ -152,6 +152,7 @@ module ActionView included do setup :setup_with_controller + ActiveSupport.run_load_hooks(:action_view_test_case, self) end private -- cgit v1.2.3