diff --git a/spec/models/topic_user_spec.rb b/spec/models/topic_user_spec.rb index 6b6d886f050..cb0a3813592 100644 --- a/spec/models/topic_user_spec.rb +++ b/spec/models/topic_user_spec.rb @@ -250,6 +250,28 @@ describe TopicUser do expect(topic_new_user.notifications_reason_id).to eq(TopicUser.notification_reasons[:created_post]) end + it 'should update tracking state when 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=2 + 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[:watching]) + + 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[:watching]) + end + + it 'should not update tracking state when 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=3 + 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[:watching]) + 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])