-
-
Notifications
You must be signed in to change notification settings - Fork 494
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
40 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
require "active_storage/engine" | ||
require "action_cable/engine" | ||
require "sentry/rails/error_subscriber" | ||
|
||
def run_pre_initialize_cleanup | ||
# Zeitwerk checks if registered loaders load paths repeatedly and raises error if that happens. | ||
# And because every new Rails::Application instance registers its own loader, we need to clear previously registered ones from Zeitwerk. | ||
Zeitwerk::Registry.loaders.clear | ||
|
||
# Rails removes the support of multiple instances, which includes freezing some setting values. | ||
# This is the workaround to avoid FrozenError. Related issue: https://github.com/rails/rails/issues/42319 | ||
ActiveSupport::Dependencies.autoload_once_paths = [] | ||
ActiveSupport::Dependencies.autoload_paths = [] | ||
|
||
# there are a few Rails initializers/finializers that register hook to the executor | ||
# because the callbacks are stored inside the `ActiveSupport::Executor` class instead of an instance | ||
# the callbacks duplicate after each time we initialize the application and cause issues when they're executed | ||
ActiveSupport::Executor.reset_callbacks(:run) | ||
ActiveSupport::Executor.reset_callbacks(:complete) | ||
|
||
# Rails uses this module to set a global context for its ErrorReporter feature. | ||
# this needs to be cleared so previously set context won't pollute later reportings (see ErrorSubscriber). | ||
ActiveSupport::ExecutionContext.clear | ||
|
||
ActionCable::Channel::Base.reset_callbacks(:subscribe) | ||
ActionCable::Channel::Base.reset_callbacks(:unsubscribe) | ||
|
||
# Rails 7.1 stores the error reporter directly under the ActiveSupport class. | ||
# So we need to make sure the subscriber is not subscribed unexpectedly before any tests | ||
ActiveSupport.error_reporter.unsubscribe(Sentry::Rails::ErrorSubscriber) | ||
end | ||
|
||
def configure_app(app) | ||
app.config.active_storage.service = :test | ||
app.config.enable_reloading = false | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters