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.
This commit is contained in:
Mike Dalessio
2025-05-07 15:54:29 -04:00
parent ff560e8fb6
commit c2c4def3b4
+7 -3
View File
@@ -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