mirror of
https://github.com/discourse/discourse.git
synced 2025-10-03 17:21:20 +08:00
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.
This commit is contained in:
parent
14ee6bd67d
commit
ac1d0e38ce
1 changed files with 7 additions and 1 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue