mirror of
https://github.com/discourse/discourse.git
synced 2025-05-22 03:21:12 +08:00
FIX: Correct behavior of auto-notification state updating to exclude when the topic already has a state of normal/muted
This commit is contained in:
@ -272,6 +272,28 @@ describe TopicUser do
|
||||
expect(tu.notification_level).to eq(TopicUser.notification_levels[:watching])
|
||||
end
|
||||
|
||||
it 'should not update tracking state when state manually set to normal you reply' do
|
||||
new_user.user_option.update_column(:notification_level_when_replying, 3)
|
||||
post_creator.create
|
||||
TopicUser.exec_sql("UPDATE topic_users set notification_level=1
|
||||
WHERE topic_id = :topic_id AND user_id = :user_id", topic_id: topic_new_user.topic_id, user_id: topic_new_user.user_id)
|
||||
TopicUser.auto_notification(topic_new_user.user_id, topic_new_user.topic_id, TopicUser.notification_reasons[:created_post], TopicUser.notification_levels[:tracking])
|
||||
|
||||
tu = TopicUser.find_by(user_id: topic_new_user.user_id, topic_id: topic_new_user.topic_id)
|
||||
expect(tu.notification_level).to eq(TopicUser.notification_levels[:regular])
|
||||
end
|
||||
|
||||
it 'should not update tracking state when state manually set to muted you reply' do
|
||||
new_user.user_option.update_column(:notification_level_when_replying, 3)
|
||||
post_creator.create
|
||||
TopicUser.exec_sql("UPDATE topic_users set notification_level=0
|
||||
WHERE topic_id = :topic_id AND user_id = :user_id", topic_id: topic_new_user.topic_id, user_id: topic_new_user.user_id)
|
||||
TopicUser.auto_notification(topic_new_user.user_id, topic_new_user.topic_id, TopicUser.notification_reasons[:created_post], TopicUser.notification_levels[:tracking])
|
||||
|
||||
tu = TopicUser.find_by(user_id: topic_new_user.user_id, topic_id: topic_new_user.topic_id)
|
||||
expect(tu.notification_level).to eq(TopicUser.notification_levels[:muted])
|
||||
end
|
||||
|
||||
it 'should not automatically track topics you reply to and have set state manually' do
|
||||
post_creator.create
|
||||
TopicUser.change(new_user, topic, notification_level: TopicUser.notification_levels[:regular])
|
||||
|
Reference in New Issue
Block a user