A platform for community discussion. Free, open, simple.
FIX: prevents exception when last reply has deleted user (#25852)
Joffrey JAFFEUXa1d7548869a3
diff --git a/plugins/chat/app/serializers/chat/thread_preview_serializer.rb b/plugins/chat/app/serializers/chat/thread_preview_serializer.rbindex 1ec04c3504f..e7fb373d11c 100644--- a/plugins/chat/app/serializers/chat/thread_preview_serializer.rb+++ b/plugins/chat/app/serializers/chat/thread_preview_serializer.rb@@ -32,7 +32,7 @@ module Chatenddef last_reply_user- object.last_message.user+ object.last_message.user || Chat::NullUser.newenddef include_participant_data?diff --git a/plugins/chat/spec/system/thread_preview_spec.rb b/plugins/chat/spec/system/thread_preview_spec.rbindex a4f87233067..77a29f61a91 100644--- a/plugins/chat/spec/system/thread_preview_spec.rb+++ b/plugins/chat/spec/system/thread_preview_spec.rb@@ -46,6 +46,17 @@ describe "Thread preview", type: :system doexpect(channel_page.messages).to have_message(id: message_1.id)expect(channel_page).to have_thread_indicator(message_1)end++ context "when the user of the preview has been deleted" do+ before { thread_1_message_1.user.destroy! }++ it "shows a deleted user" do+ chat_page.visit_channel(channel_1)++ expect(channel_page).to have_thread_indicator(message_1)+ expect(channel_page).to have_css(".chat-user-avatar[data-username='deleted']")+ end+ endendcontext "when message has thread with deleted original message" do