From 3156fbd7702b07fa9fe3e9577d74499d3b2fbe9c Mon Sep 17 00:00:00 2001 From: Mike Dalessio Date: Mon, 30 Jun 2025 23:43:25 -0400 Subject: [PATCH] Fix notification rendering on card closure events where the closure no longer exists, possibly due to being reopened. Previously, fragment caching generally prevented any problems, but if the cache is busted for any reason (like Andy did in c7eeb56c), then the previous logic would raise an exception like "undefined method 'reason' for nil". So, if the closure no longer exists, let's just note that it was closed, and by who. --- app/helpers/notifications_helper.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/helpers/notifications_helper.rb b/app/helpers/notifications_helper.rb index d36a034ad..d354d1a8d 100644 --- a/app/helpers/notifications_helper.rb +++ b/app/helpers/notifications_helper.rb @@ -10,7 +10,12 @@ module NotificationsHelper name = event.creator.name case event_notification_action(event) - when "card_closed" then "Closed as “#{event.card.closure.reason}” by #{name}" + when "card_closed" + if event.card.closure + "Closed as “#{event.card.closure.reason}” by #{name}" + else + "Closed by #{name}" + end when "card_reopened" then "Reopened by #{name}" when "card_published" then "Added by #{name}" when "comment_created" then comment_notification_body(event)