FIX: prevents exception when last reply has deleted user (#25852)
Prior to this fix, if the last message of a thread had been made by a deleted user it would cause an exception as we would have no user to display, this commit uses a solution we have been using at other places: the null pattern, through the use of `Chat::NullUser.new`.
This commit is contained in:
parent
1bd9ca11e7
commit
a1d7548869
|
@ -32,7 +32,7 @@ module Chat
|
||||||
end
|
end
|
||||||
|
|
||||||
def last_reply_user
|
def last_reply_user
|
||||||
object.last_message.user
|
object.last_message.user || Chat::NullUser.new
|
||||||
end
|
end
|
||||||
|
|
||||||
def include_participant_data?
|
def include_participant_data?
|
||||||
|
|
|
@ -46,6 +46,17 @@ describe "Thread preview", type: :system do
|
||||||
expect(channel_page.messages).to have_message(id: message_1.id)
|
expect(channel_page.messages).to have_message(id: message_1.id)
|
||||||
expect(channel_page).to have_thread_indicator(message_1)
|
expect(channel_page).to have_thread_indicator(message_1)
|
||||||
end
|
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
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context "when message has thread with deleted original message" do
|
context "when message has thread with deleted original message" do
|
||||||
|
|
Loading…
Reference in New Issue