mirror of
https://github.com/discourse/discourse.git
synced 2024-11-27 18:33:37 +08:00
bc23dcd30b
When a user archives a personal message, they are redirected back to the
inbox and will refresh the list of the topics for the given filter.
Publishing an event to the user results in an incorrect incoming message
because the list of topics has already been refreshed.
This does mean that if a user has two tabs opened, the non-active tab
will not receive the incoming message but at this point we do not think
the technical trade-offs are worth it to support this feature. We
basically have to somehow exclude a client from an incoming message
which is not easy to do.
Follow-up to fc1fd1b416
40 lines
1.1 KiB
Ruby
40 lines
1.1 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
require 'rails_helper'
|
|
|
|
describe UserArchivedMessage do
|
|
fab!(:user) { Fabricate(:user) }
|
|
fab!(:user_2) { Fabricate(:user) }
|
|
|
|
fab!(:private_message) do
|
|
create_post(
|
|
user: user,
|
|
skip_validations: true,
|
|
target_usernames: [user_2.username, user.username].join(","),
|
|
archetype: Archetype.private_message
|
|
).topic
|
|
end
|
|
|
|
describe '.move_to_inbox!' do
|
|
it 'moves topic back to inbox correctly' do
|
|
UserArchivedMessage.archive!(user.id, private_message)
|
|
|
|
expect do
|
|
UserArchivedMessage.move_to_inbox!(user.id, private_message)
|
|
end.to change { private_message.message_archived?(user) }.from(true).to(false)
|
|
end
|
|
|
|
it 'does not move archived muted messages back to inbox' do
|
|
UserArchivedMessage.archive!(user.id, private_message)
|
|
|
|
expect(private_message.message_archived?(user)).to eq(true)
|
|
|
|
TopicUser.change(user.id, private_message.id, notification_level: TopicUser.notification_levels[:muted])
|
|
UserArchivedMessage.move_to_inbox!(user.id, private_message)
|
|
|
|
expect(private_message.message_archived?(user)).to eq(true)
|
|
end
|
|
end
|
|
|
|
end
|