DEV: Change use of Redis `flushall` to `flushdb`.

FLUSHALL removes all keys from all databases. Instead we only want to
remove keys from the current Redis database.
This commit is contained in:
Guo Xiang Tan 2020-05-19 10:20:00 +08:00
parent f99f6ca111
commit 96c02caba7
No known key found for this signature in database
GPG Key ID: FBD110179AAC1F20
15 changed files with 18 additions and 18 deletions

View File

@ -2,5 +2,5 @@
if Rails.env.development? && ENV['DISCOURSE_FLUSH_REDIS']
puts "Flushing redis (development mode)"
Discourse.redis.flushall
Discourse.redis.flushdb
end

View File

@ -472,7 +472,7 @@ describe DiscourseNarrativeBot::TrackSelector do
let(:post) { Fabricate(:post, topic: topic) }
after do
Discourse.redis.flushall
Discourse.redis.flushdb
end
describe 'when random reply massage has been displayed in the last 6 hours' do

View File

@ -237,7 +237,7 @@ describe Auth::DefaultCurrentUserProvider do
end
after do
Discourse.redis.flushall
Discourse.redis.flushdb
end
it "should not update last seen for suspended users" do

View File

@ -21,11 +21,11 @@ describe DiscourseRedis do
let(:raw_redis) { Redis.new(DiscourseRedis.config) }
before do
raw_redis.flushall
raw_redis.flushdb
end
after do
raw_redis.flushall
raw_redis.flushdb
end
describe 'when namespace is enabled' do

View File

@ -5,7 +5,7 @@ require "email/processor"
describe Email::Processor do
after do
Discourse.redis.flushall
Discourse.redis.flushdb
end
let(:from) { "foo@bar.com" }

View File

@ -508,7 +508,7 @@ describe PrettyText do
['apple', 'banana'].each { |w| Fabricate(:watched_word, word: w, action: WatchedWord.actions[:censor]) }
expect(PrettyText.cook("# banana")).not_to include('banana')
ensure
Discourse.redis.flushall
Discourse.redis.flushdb
end
end
end
@ -1166,7 +1166,7 @@ HTML
end
describe "censoring" do
after(:all) { Discourse.redis.flushall }
after(:all) { Discourse.redis.flushdb }
def expect_cooked_match(raw, expected_cooked)
expect(PrettyText.cook(raw)).to eq(expected_cooked)

View File

@ -22,7 +22,7 @@ RSpec.describe Jobs::BookmarkReminderNotifications do
bookmark1.update_column(:reminder_at, five_minutes_ago - 10.minutes)
bookmark2.update_column(:reminder_at, five_minutes_ago - 5.minutes)
bookmark3.update_column(:reminder_at, five_minutes_ago)
Discourse.redis.flushall
Discourse.redis.flushdb
end
it "sends every reminder and marks the reminder_at to nil for all bookmarks, as well as last sent date" do

View File

@ -8,7 +8,7 @@ RSpec.describe BookmarkReminderNotificationHandler do
fab!(:user) { Fabricate(:user) }
before do
Discourse.redis.flushall
Discourse.redis.flushdb
end
describe "#send_notification" do

View File

@ -33,7 +33,7 @@ describe Topic do
describe 'censored words' do
after do
Discourse.redis.flushall
Discourse.redis.flushdb
end
describe 'when title contains censored words' do

View File

@ -35,7 +35,7 @@ RSpec.describe Admin::BackupsController do
end
after do
Discourse.redis.flushall
Discourse.redis.flushdb
@paths&.each { |path| File.delete(path) if File.exists?(path) }
@paths = nil

View File

@ -293,7 +293,7 @@ RSpec.describe Admin::UsersController do
fab!(:another_user) { Fabricate(:coding_horror) }
after do
Discourse.redis.flushall
Discourse.redis.flushdb
end
it "raises an error when the user doesn't have permission" do

View File

@ -26,11 +26,11 @@ describe SearchController do
before do
# TODO be a bit more strategic here instead of junking
# all of redis
Discourse.redis.flushall
Discourse.redis.flushdb
end
after do
Discourse.redis.flushall
Discourse.redis.flushdb
end
context "when overloaded" do

View File

@ -2127,7 +2127,7 @@ RSpec.describe TopicsController do
let(:topic) { post.topic }
after do
Discourse.redis.flushall
Discourse.redis.flushdb
end
it 'returns first post of the topic' do

View File

@ -3,7 +3,7 @@
require "rails_helper"
describe WebhooksController do
before { Discourse.redis.flushall }
before { Discourse.redis.flushdb }
let(:email) { "em@il.com" }
let(:message_id) { "12345@il.com" }

View File

@ -7,7 +7,7 @@ describe WordWatcher do
let(:raw) { "Do you like liquorice?\n\nI really like them. One could even say that I am *addicted* to liquorice. Anf if\nyou can mix it up with some anise, then I'm in heaven ;)" }
after do
Discourse.redis.flushall
Discourse.redis.flushdb
end
describe '.word_matcher_regexp' do