From ac1d0e38ce0dc0c8ca59912c0a314bcf23c1251a Mon Sep 17 00:00:00 2001 From: Martin Brennan Date: Tue, 30 Sep 2025 17:44:41 +1000 Subject: [PATCH] DEV: Properly clean up global setting overrides in specs (#35058) In the `SiteSettingExtension`, when calling `SiteSetting.send(:setting_name, value)`, if the setting counts as a global one, we add it to the list of hidden and shadowed site settings in memory. However, when using the `global_setting` helper in specs, we were not cleaning up these overrides after the spec finished, leading to potential flakiness in tests that rely on the visibility of site settings. The fix is to just remove the setting from the hidden and shadowed list after the spec is done. --- spec/rails_helper.rb | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb index ab2deb969dd..b48a76be4f1 100644 --- a/spec/rails_helper.rb +++ b/spec/rails_helper.rb @@ -939,11 +939,17 @@ def before_next_spec(&callback) end def global_setting(name, value) + SiteSetting.hidden_settings_provider.remove_hidden(name) + SiteSetting.shadowed_settings.delete(name) GlobalSetting.reset_s3_cache! GlobalSetting.stubs(name).returns(value) - before_next_spec { GlobalSetting.reset_s3_cache! } + before_next_spec do + SiteSetting.hidden_settings_provider.remove_hidden(name) + SiteSetting.shadowed_settings.delete(name) + GlobalSetting.reset_s3_cache! + end end def set_cdn_url(cdn_url)