BUGFIX: tracking categories was not implemented

This commit is contained in:
Sam
2014-06-02 13:55:01 +10:00
parent 7cba724fdb
commit 0979e7b9af
5 changed files with 21 additions and 1 deletions

View File

@ -31,15 +31,24 @@ describe CategoryUser do
it 'should operate correctly' do
watched_category = Fabricate(:category)
muted_category = Fabricate(:category)
tracked_category = Fabricate(:category)
user = Fabricate(:user)
CategoryUser.create!(user: user, category: watched_category, notification_level: CategoryUser.notification_levels[:watching])
CategoryUser.create!(user: user, category: muted_category, notification_level: CategoryUser.notification_levels[:muted])
CategoryUser.create!(user: user, category: tracked_category, notification_level: CategoryUser.notification_levels[:tracking])
watched_post = create_post(category: watched_category)
muted_post = create_post(category: muted_category)
tracked_post = create_post(category: tracked_category)
Notification.where(user_id: user.id, topic_id: watched_post.topic_id).count.should == 1
Notification.where(user_id: user.id, topic_id: tracked_post.topic_id).count.should == 0
tu = TopicUser.get(tracked_post.topic, user)
tu.notification_level.should == TopicUser.notification_levels[:tracking]
tu.notifications_reason_id.should == TopicUser.notification_reasons[:auto_track_category]
tu = TopicUser.get(muted_post.topic, user)
tu.notification_level.should == TopicUser.notification_levels[:muted]