Skip to content

Commit e56cee4

Browse files
committed
Ensure that our load hooks really for real run after Rails
While changing the code to be in an `on_load` hook fixed some of the issues with load hook order, it didn't catch all of them. Rails runs its hooks in initializers, meaning they'll be defined after our own hooks which are not in an initializer. Fixes #24
1 parent b128f8f commit e56cee4

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

lib/rails-controller-testing.rb

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,19 @@
44
require 'rails/controller/testing/template_assertions'
55
require 'rails/controller/testing/version'
66

7-
ActiveSupport.on_load(:action_controller) do
8-
ActionController::TestCase.include Rails::Controller::Testing::TestProcess
9-
ActionController::TestCase.include Rails::Controller::Testing::TemplateAssertions
7+
class Rails::Controller::Testing::Railtie < Rails::Railtie
8+
initializer "rails_controller_testing" do
9+
ActiveSupport.on_load(:action_controller) do
10+
ActionController::TestCase.include Rails::Controller::Testing::TestProcess
11+
ActionController::TestCase.include Rails::Controller::Testing::TemplateAssertions
1012

11-
ActionDispatch::IntegrationTest.include Rails::Controller::Testing::TemplateAssertions
12-
ActionDispatch::IntegrationTest.include Rails::Controller::Testing::Integration
13-
ActionDispatch::IntegrationTest.include Rails::Controller::Testing::TestProcess
14-
end
13+
ActionDispatch::IntegrationTest.include Rails::Controller::Testing::TemplateAssertions
14+
ActionDispatch::IntegrationTest.include Rails::Controller::Testing::Integration
15+
ActionDispatch::IntegrationTest.include Rails::Controller::Testing::TestProcess
16+
end
1517

16-
ActiveSupport.on_load(:action_view) do
17-
ActionView::TestCase.include Rails::Controller::Testing::TemplateAssertions
18+
ActiveSupport.on_load(:action_view) do
19+
ActionView::TestCase.include Rails::Controller::Testing::TemplateAssertions
20+
end
21+
end
1822
end

0 commit comments

Comments
 (0)