Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run Railtie from the tests so that we can detect bugs inside Railtie #556

Merged
merged 4 commits into from
Jan 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions lib/jbuilder/railtie.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 10 additions & 1 deletion test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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