FIX: Update last_read_message_id when moving chat messages (#22643)

This commit is contained in:
Jan Cernik
2023-07-18 12:46:54 -03:00
committed by GitHub
parent 3d554aa10e
commit d258bda2fe
2 changed files with 30 additions and 0 deletions

View File

@ -183,6 +183,31 @@ describe Chat::MessageMover do
expect(message3.reload.thread).to eq(thread)
end
it "updates the tracking to the last non-deleted channel message for users whose last_read_message_id was the moved message" do
membership_1 =
Fabricate(
:user_chat_channel_membership,
chat_channel: source_channel,
last_read_message: message1,
)
membership_2 =
Fabricate(
:user_chat_channel_membership,
chat_channel: source_channel,
last_read_message: message2,
)
membership_3 =
Fabricate(
:user_chat_channel_membership,
chat_channel: source_channel,
last_read_message: message3,
)
move!([message2.id])
expect(membership_1.reload.last_read_message_id).to eq(message1.id)
expect(membership_2.reload.last_read_message_id).to eq(message3.id)
expect(membership_3.reload.last_read_message_id).to eq(message3.id)
end
context "when a thread original message is moved" do
it "creates a new thread for the messages left behind in the old channel" do
message4 =