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

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.

diff --git a/config/initializers/001-redis.rb b/config/initializers/001-redis.rb
index e484415..d11303a 100644
--- a/config/initializers/001-redis.rb
+++ b/config/initializers/001-redis.rb
@@ -2,5 +2,5 @@
 
 if Rails.env.development? && ENV['DISCOURSE_FLUSH_REDIS']
   puts "Flushing redis (development mode)"
-  Discourse.redis.flushall
+  Discourse.redis.flushdb
 end
diff --git a/plugins/discourse-narrative-bot/spec/discourse_narrative_bot/track_selector_spec.rb b/plugins/discourse-narrative-bot/spec/discourse_narrative_bot/track_selector_spec.rb
index 4e24b9f..6914dff 100644
--- a/plugins/discourse-narrative-bot/spec/discourse_narrative_bot/track_selector_spec.rb
+++ b/plugins/discourse-narrative-bot/spec/discourse_narrative_bot/track_selector_spec.rb
@@ -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
diff --git a/spec/components/auth/default_current_user_provider_spec.rb b/spec/components/auth/default_current_user_provider_spec.rb
index 1b698cb..8c14233 100644
--- a/spec/components/auth/default_current_user_provider_spec.rb
+++ b/spec/components/auth/default_current_user_provider_spec.rb
@@ -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
diff --git a/spec/components/discourse_redis_spec.rb b/spec/components/discourse_redis_spec.rb
index 6d4af1d..abc9a59 100644
--- a/spec/components/discourse_redis_spec.rb
+++ b/spec/components/discourse_redis_spec.rb
@@ -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
diff --git a/spec/components/email/processor_spec.rb b/spec/components/email/processor_spec.rb
index 3fe4ab4..6069555 100644
--- a/spec/components/email/processor_spec.rb
+++ b/spec/components/email/processor_spec.rb
@@ -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" }
diff --git a/spec/components/pretty_text_spec.rb b/spec/components/pretty_text_spec.rb
index 8969a52..c5ef73c 100644
--- a/spec/components/pretty_text_spec.rb
+++ b/spec/components/pretty_text_spec.rb
@@ -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)
diff --git a/spec/jobs/bookmark_reminder_notifications_spec.rb b/spec/jobs/bookmark_reminder_notifications_spec.rb
index 0bcfa0b..25379d0 100644
--- a/spec/jobs/bookmark_reminder_notifications_spec.rb
+++ b/spec/jobs/bookmark_reminder_notifications_spec.rb
@@ -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
diff --git a/spec/lib/bookmark_reminder_notification_handler_spec.rb b/spec/lib/bookmark_reminder_notification_handler_spec.rb
index 6af860f..3d9a6d7 100644
--- a/spec/lib/bookmark_reminder_notification_handler_spec.rb
+++ b/spec/lib/bookmark_reminder_notification_handler_spec.rb
@@ -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
diff --git a/spec/models/topic_spec.rb b/spec/models/topic_spec.rb
index d381579..d1d5d1c 100644
--- a/spec/models/topic_spec.rb
+++ b/spec/models/topic_spec.rb
@@ -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
diff --git a/spec/requests/admin/backups_controller_spec.rb b/spec/requests/admin/backups_controller_spec.rb
index 466d4a9..03b9245 100644
--- a/spec/requests/admin/backups_controller_spec.rb
+++ b/spec/requests/admin/backups_controller_spec.rb
@@ -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
diff --git a/spec/requests/admin/users_controller_spec.rb b/spec/requests/admin/users_controller_spec.rb
index f62407d..099372c 100644
--- a/spec/requests/admin/users_controller_spec.rb
+++ b/spec/requests/admin/users_controller_spec.rb
@@ -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
diff --git a/spec/requests/search_controller_spec.rb b/spec/requests/search_controller_spec.rb
index 947bd87..dac1169 100644
--- a/spec/requests/search_controller_spec.rb
+++ b/spec/requests/search_controller_spec.rb
@@ -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
diff --git a/spec/requests/topics_controller_spec.rb b/spec/requests/topics_controller_spec.rb
index 726b922..9649f57 100644
--- a/spec/requests/topics_controller_spec.rb
+++ b/spec/requests/topics_controller_spec.rb
@@ -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
diff --git a/spec/requests/webhooks_controller_spec.rb b/spec/requests/webhooks_controller_spec.rb
index 7772e0e..580c0c7 100644
--- a/spec/requests/webhooks_controller_spec.rb
+++ b/spec/requests/webhooks_controller_spec.rb
@@ -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" }
diff --git a/spec/services/word_watcher_spec.rb b/spec/services/word_watcher_spec.rb
index 0f6a2b7..5cf70b6 100644
--- a/spec/services/word_watcher_spec.rb
+++ b/spec/services/word_watcher_spec.rb
@@ -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

GitHub sha: 96c02cab