DEV: Call Discourse.redis.flushdb after the end of each test (#29117)

There have been too many flaky tests as a result of leaking state in
Redis so it is easier to resolve them by ensuring we flush Redis'
database.

Locally on my machine, calling `Discourse.redis.flushdb` takes around
0.1ms which means this change will have very little impact on test
runtimes.
This commit is contained in:
Alan Guo Xiang Tan
2024-10-09 07:19:31 +08:00
committed by GitHub
parent 44fe8c62d6
commit ed6c9d1545
38 changed files with 10 additions and 154 deletions

View File

@ -932,8 +932,6 @@ RSpec.describe ApplicationController do
context "with rate limits" do
before { RateLimiter.enable }
use_redis_snapshotting
it "serves a LimitExceeded error in the preferred locale" do
SiteSetting.max_likes_per_day = 1
post1 = Fabricate(:post)
@ -1156,8 +1154,6 @@ RSpec.describe ApplicationController do
before { RateLimiter.enable }
use_redis_snapshotting
it "is included when API key is rate limited" do
global_setting :max_admin_api_reqs_per_minute, 1
api_key = ApiKey.create!(user_id: admin.id).key
@ -1208,8 +1204,6 @@ RSpec.describe ApplicationController do
SiteSetting.slow_down_crawler_user_agents = "badcrawler|problematiccrawler"
end
use_redis_snapshotting
it "are rate limited" do
now = Time.zone.now
freeze_time now