diff --git a/lib/jbuilder/railtie.rb b/lib/jbuilder/railtie.rb index 8828b05..2aeefbb 100644 --- a/lib/jbuilder/railtie.rb +++ b/lib/jbuilder/railtie.rb @@ -16,9 +16,11 @@ module ApiRendering end end - ActiveSupport.on_load :action_controller_api do - include ActionController::Helpers - include ActionController::ImplicitRender + ActiveSupport.on_load :action_controller do + if name == 'ActionController::API' + include ActionController::Helpers + include ActionController::ImplicitRender + end end end end diff --git a/test/test_helper.rb b/test/test_helper.rb index 299ff8d..d985da9 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -8,6 +8,8 @@ require "active_support/cache/memory_store" require "active_support/json" require "active_model" +require 'action_controller/railtie' +require 'action_view/railtie' require "active_support/testing/autorun" require "mocha/minitest" @@ -35,4 +37,11 @@ class Racer < Struct.new(:id, :name) include ActiveModel::Conversion end -ActionView::Template.register_template_handler :jbuilder, JbuilderHandler +# Instantiate an Application in order to trigger the initializers +Class.new(Rails::Application) do + config.secret_key_base = 'secret' + config.eager_load = false +end.initialize! + +# Touch AV::Base in order to trigger :action_view on_load hook before running the tests +ActionView::Base.inspect