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

Fix double registration of :turbo_stream Renderer #562

Merged
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: 3 additions & 5 deletions lib/turbo/engine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,9 @@ class Engine < Rails::Engine
end

initializer "turbo.renderer" do
ActiveSupport.on_load(:action_controller) do
ActionController::Renderers.add :turbo_stream do |turbo_streams_html, options|
self.content_type = Mime[:turbo_stream] if media_type.nil?
turbo_streams_html
end
ActionController::Renderers.add :turbo_stream do |turbo_streams_html, options|
self.content_type = Mime[:turbo_stream] if media_type.nil?
turbo_streams_html
end
end

Expand Down
2 changes: 2 additions & 0 deletions test/dummy/app/controllers/api/application_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
class Api::ApplicationController < ActionController::API
end
2 changes: 0 additions & 2 deletions test/dummy/app/mailboxes/application_mailbox.rb
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the removal of the Mailboxes related to engine changes?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was to enable eager_load since neither the Action Mailbox nor the Action Mailer railties are required in config/application.rb. I think eager_load has merits on its own, but it also makes it easier to demonstrate the issue in this PR because we don't have to use the Api::ApplicationController in a test.

This file was deleted.

4 changes: 0 additions & 4 deletions test/dummy/app/mailboxes/messages_mailbox.rb

This file was deleted.

4 changes: 0 additions & 4 deletions test/dummy/app/mailers/application_mailer.rb

This file was deleted.

2 changes: 1 addition & 1 deletion test/dummy/config/environments/test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# Do not eager load code on boot. This avoids loading your whole application
# just for the purpose of running a single test. If you are using a tool that
# preloads Rails for running tests, you may have to set it to true.
config.eager_load = false
config.eager_load = ENV["CI"].present?

# Configure public file server for tests with Cache-Control for performance.
config.public_file_server.enabled = true
Expand Down