DEV: Add chat_mention notification type (#13784)

DEV: Add chat_mention notification type (#13784)

diff --git a/app/models/notification.rb b/app/models/notification.rb
index b5a07a3..a22be0e 100644
--- a/app/models/notification.rb
+++ b/app/models/notification.rb
@@ -75,7 +75,7 @@ class Notification < ActiveRecord::Base
     DB.exec(<<~SQL)
       DELETE
         FROM notifications n
-       WHERE high_priority
+       WHERE high_priority AND notification_type <> #{types[:chat_mention].to_i}
          AND NOT EXISTS (
             SELECT 1
               FROM posts p
@@ -116,7 +116,8 @@ class Notification < ActiveRecord::Base
                         reaction: 25,
                         votes_released: 26,
                         event_reminder: 27,
-                        event_invitation: 28
+                        event_invitation: 28,
+                        chat_mention: 29
                        )
   end
 
diff --git a/spec/models/notification_spec.rb b/spec/models/notification_spec.rb
index a97537a..e609a60 100644
--- a/spec/models/notification_spec.rb
+++ b/spec/models/notification_spec.rb
@@ -341,6 +341,16 @@ describe Notification do
 
       expect(Notification.count).to eq(2)
     end
+
+    it 'does not delete chat_message notifications' do
+      user = Fabricate(:user)
+      Notification.create!(read: false, user_id: user.id, topic_id: nil, post_number: nil, data: '[]',
+                           notification_type: Notification.types[:chat_mention])
+
+      expect {
+        Notification.ensure_consistency!
+      }.to_not change { Notification.count }
+    end
   end
 
   describe '.filter_by_consolidation_data' do

GitHub sha: 80950d7b28a621e57eb59caf042ec01408e79e37

This commit appears in #13784 which was approved by eviltrout. It was merged by markvanlan.