mirror of
https://github.com/discourse/discourse.git
synced 2024-11-22 15:52:11 +08:00
916495e0a1
What is the problem? In the test environement, we were calling `SiteSetting.setting` directly to introduce new site settings. However, this leads to changes in state of the SiteSettings hash that is stored in memory as test runs. Changing or leaking states when running tests is one of the major contributors of test flakiness. An example of how this resulted in test flakiness is our `spec/integrity/i18n_spec.rb` spec file which had a test case that would fail because a new "plugin_setting" site setting was registered in another test case but the site setting did not have translations for the site setting set. What is the fix? There are a couple of changes being introduced in this commit: 1. Make `SiteSetting.setting` a private method as it is not safe to be exposed as a public method of the `SiteSetting` class 2. Change test cases to use existing site settings in Discourse instead of creating custom site settings. Existing site settings are not removed often so we don't really need to dynamically add new site settings in test cases. Even if the site settings being used in test cases are removed, updating the test cases to rely on other site settings is a very easy change. 3. Set up a plugin instance in the test environment as a "fixture" instead of having each test create its own plugin instance. |
||
---|---|---|
.. | ||
versioning | ||
bookmarkable_helper.rb | ||
common_basic_reviewable_serializer.rb | ||
concurrency.rb | ||
diagnostics_helper.rb | ||
discourse_event_helper.rb | ||
fake_bookmark_hashtag_data_source.rb | ||
fake_logger.rb | ||
fake_s3.rb | ||
fast_image_helpers.rb | ||
final_destination_helper.rb | ||
helpers.rb | ||
imap_helper.rb | ||
integration_helpers.rb | ||
match_html_matcher.rb | ||
mock_git_importer.rb | ||
negated_matcher.rb | ||
onebox_helpers.rb | ||
rate_limit_matcher.rb | ||
sample_plugin_site_settings.yml | ||
session_controller_helper_routes.rb | ||
shared_examples_for_stats_cacheable.rb | ||
sidekiq_helpers.rb | ||
site_settings_helpers.rb | ||
system_helpers.rb | ||
test_second_factor_action.rb | ||
time_matcher.rb | ||
topic_guardian_can_see_consistency_check.rb | ||
ts_vector_matcher.rb | ||
uploads_helpers.rb | ||
user_sidebar_serializer_attributes.rb | ||
webauthn_integration_helpers.rb |