Add spec for auto notification update

It should update the topic subscription so long as what is being requested is higher than what is currently set for the user and the given topic
It should not update the topic subscription if the requested subscription is less than what is currently set for the user and given topic
This commit is contained in:
cpradio 2017-04-14 18:30:01 -04:00
parent ed2e62f845
commit e3ad50de05
1 changed files with 22 additions and 0 deletions

View File

@ -250,6 +250,28 @@ describe TopicUser do
expect(topic_new_user.notifications_reason_id).to eq(TopicUser.notification_reasons[:created_post]) expect(topic_new_user.notifications_reason_id).to eq(TopicUser.notification_reasons[:created_post])
end 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 it 'should not automatically track topics you reply to and have set state manually' do
post_creator.create post_creator.create
TopicUser.change(new_user, topic, notification_level: TopicUser.notification_levels[:regular]) TopicUser.change(new_user, topic, notification_level: TopicUser.notification_levels[:regular])