Skip to content

Commit d7edc11

Browse files
committed
WIP
1 parent 50cd1fe commit d7edc11

File tree

1 file changed

+17
-0
lines changed
  • sentry-rails/spec/dummy/test_rails_app/config/applications

1 file changed

+17
-0
lines changed

sentry-rails/spec/dummy/test_rails_app/config/applications/latest.rb

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff 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
4562
end

0 commit comments

Comments
 (0)