From c2c4def3b4b18fd779ec62dc0d33b43022948a6e Mon Sep 17 00:00:00 2001 From: Mike Dalessio Date: Wed, 7 May 2025 15:54:29 -0400 Subject: [PATCH] Ensure that cards with an empty title aren't mysterious in notifs Use something like "Card 55" instead of it being blank or raising an exception. --- app/helpers/notifications_helper.rb | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/app/helpers/notifications_helper.rb b/app/helpers/notifications_helper.rb index 3baaf7aab..19ca08745 100644 --- a/app/helpers/notifications_helper.rb +++ b/app/helpers/notifications_helper.rb @@ -1,9 +1,9 @@ module NotificationsHelper def event_notification_title(event) case event_notification_action(event) - when "comment_created" then "RE: " + event.eventable.card.title - when "card_assigned" then "Assigned to #{event.assignees.pluck(:name).to_sentence}: " + event.eventable.title - else event.eventable.title + when "comment_created" then "RE: #{card_notification_title(event.eventable.card)}" + when "card_assigned" then "Assigned to #{event.assignees.pluck(:name).to_sentence}: #{card_notification_title(event.eventable)}" + else card_notification_title(event.eventable) end end @@ -59,4 +59,8 @@ module NotificationsHelper comment = event.eventable "#{strip_tags(comment.body_html).blank? ? "#{event.creator.name} replied" : "#{event.creator.name}:" } #{strip_tags(comment.body_html).truncate(200)}" end + + def card_notification_title(card) + card.title.presence || "Card #{card.id}" + end end