File tree Expand file tree Collapse file tree 1 file changed +17
-0
lines changed
sentry-rails/spec/dummy/test_rails_app/config/applications Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -41,5 +41,22 @@ def before_initialize!
4141
4242 super
4343 end
44+
45+ def after_initialize!
46+ super
47+ # ActiveSupport uses @loaded and @run_once to track what has been loaded/executed.
48+ # These accumulate between test runs and can cause state from one test to leak into subsequent tests.
49+ # We clear them AFTER initialization completes (including config.after_initialize callbacks) to prevent leaks.
50+ # Note: We don't clear @load_hooks here as they are needed for lazy loading and are registered when
51+ # railtie classes are loaded, not during initialization. Clearing them would break lazy loading.
52+ # Instead, @load_hooks are naturally clean between tests since each test creates a new application instance.
53+ if ActiveSupport . instance_variable_defined? ( :@loaded )
54+ ActiveSupport . instance_variable_set ( :@loaded , Hash . new { |h , k | h [ k ] = [ ] } )
55+ end
56+
57+ if ActiveSupport . instance_variable_defined? ( :@run_once )
58+ ActiveSupport . instance_variable_set ( :@run_once , Hash . new { |h , k | h [ k ] = [ ] } )
59+ end
60+ end
4461 end
4562end
You can’t perform that action at this time.
0 commit comments