Skip to content

Commit 3875613

Browse files
authored
Merge pull request #556 from amatsuda/run_railtie_in_tests
Run Railtie from the tests so that we can detect bugs inside Railtie
2 parents aa5a272 + 5af3835 commit 3875613

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

lib/jbuilder/railtie.rb

+5-3
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,11 @@ module ApiRendering
1616
end
1717
end
1818

19-
ActiveSupport.on_load :action_controller_api do
20-
include ActionController::Helpers
21-
include ActionController::ImplicitRender
19+
ActiveSupport.on_load :action_controller do
20+
if name == 'ActionController::API'
21+
include ActionController::Helpers
22+
include ActionController::ImplicitRender
23+
end
2224
end
2325
end
2426
end

test/test_helper.rb

+10-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
require "active_support/cache/memory_store"
99
require "active_support/json"
1010
require "active_model"
11+
require 'action_controller/railtie'
12+
require 'action_view/railtie'
1113

1214
require "active_support/testing/autorun"
1315
require "mocha/minitest"
@@ -35,4 +37,11 @@ class Racer < Struct.new(:id, :name)
3537
include ActiveModel::Conversion
3638
end
3739

38-
ActionView::Template.register_template_handler :jbuilder, JbuilderHandler
40+
# Instantiate an Application in order to trigger the initializers
41+
Class.new(Rails::Application) do
42+
config.secret_key_base = 'secret'
43+
config.eager_load = false
44+
end.initialize!
45+
46+
# Touch AV::Base in order to trigger :action_view on_load hook before running the tests
47+
ActionView::Base.inspect

0 commit comments

Comments
 (0)