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.
This commit is contained in:
Mike Dalessio
2025-06-30 23:43:25 -04:00
parent ec287b2a50
commit 3156fbd770
+6 -1
View File
@@ -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)