From 94152e4640516ad81dc11331531ee9b620bcffa1 Mon Sep 17 00:00:00 2001 From: Krzysztof Kotlarek Date: Mon, 31 Aug 2020 09:15:36 +1000 Subject: [PATCH] FIX: dont error when bookmark topic is nil (#10555) --- lib/bookmark_reminder_notification_handler.rb | 1 + spec/jobs/bookmark_reminder_notifications_spec.rb | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/lib/bookmark_reminder_notification_handler.rb b/lib/bookmark_reminder_notification_handler.rb index e01f2dca772..e0c105c5756 100644 --- a/lib/bookmark_reminder_notification_handler.rb +++ b/lib/bookmark_reminder_notification_handler.rb @@ -7,6 +7,7 @@ class BookmarkReminderNotificationHandler if bookmark.post.blank? || bookmark.post.deleted_at.present? return clear_reminder(bookmark) end + return unless bookmark.topic create_notification(bookmark) diff --git a/spec/jobs/bookmark_reminder_notifications_spec.rb b/spec/jobs/bookmark_reminder_notifications_spec.rb index 25379d0ba39..852aaba13e1 100644 --- a/spec/jobs/bookmark_reminder_notifications_spec.rb +++ b/spec/jobs/bookmark_reminder_notifications_spec.rb @@ -59,4 +59,11 @@ RSpec.describe Jobs::BookmarkReminderNotifications do end end end + + it 'will not send notification when topic is not available' do + bookmark1.topic.destroy + bookmark2.topic.destroy + bookmark3.topic.destroy + expect { subject.execute }.not_to change { Notification.where(notification_type: Notification.types[:bookmark_reminder]).count } + end end