Merge pull request #4812 from cpradio/spec-auto-notification-update

Add spec for auto notification update
This commit is contained in:
Jeff Atwood 2017-04-14 16:01:38 -07:00 committed by GitHub
commit d12ba0548c
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])