A platform for community discussion. Free, open, simple.
DEV: Skip notifications without topic_id in `ensure_consistency` (#16299)
Mark VanLandinghamb974375239c9
diff --git a/app/models/notification.rb b/app/models/notification.rbindex 823168a67a5..168f6e40c73 100644--- a/app/models/notification.rb+++ b/app/models/notification.rb@@ -64,7 +64,7 @@ class Notification < ActiveRecord::BaseDELETEFROM notifications nWHERE high_priority- AND notification_type NOT IN (#{types[:chat_mention].to_i}, #{types[:chat_message].to_i})+ AND n.topic_id IS NOT NULLAND NOT EXISTS (SELECT 1FROM posts pdiff --git a/spec/models/notification_spec.rb b/spec/models/notification_spec.rbindex 2d897b22ae4..31a4a9bc627 100644--- a/spec/models/notification_spec.rb+++ b/spec/models/notification_spec.rb@@ -340,10 +340,9 @@ describe Notification doexpect(Notification.count).to eq(2)end- it 'does not delete chat_message notifications' do+ it 'does not delete notifications that do not have a topic_id' doNotification.create!(read: false, user_id: user.id, topic_id: nil, post_number: nil, data: '[]',- notification_type: Notification.types[:chat_mention])-+ notification_type: Notification.types[:chat_mention], high_priority: true)expect {Notification.ensure_consistency!}.to_not change { Notification.count }