FIX: change **default** notification state when a topic is recategorized within 5 days of creation

This commit is contained in:
Régis Hanol
2015-08-19 22:40:20 +02:00
parent eafeec51a5
commit 9ae9aed010
3 changed files with 50 additions and 18 deletions

View File

@@ -52,8 +52,8 @@ describe CategoryUser do
end
it "watches categories that have been changed" do
watched_category = Fabricate(:category)
user = Fabricate(:user)
watched_category = Fabricate(:category)
CategoryUser.create!(user: user, category: watched_category, notification_level: CategoryUser.notification_levels[:watching])
post = create_post
@@ -65,6 +65,21 @@ describe CategoryUser do
expect(tu.notification_level).to eq TopicUser.notification_levels[:watching]
end
it "unwatches categories that have been changed" do
user = Fabricate(:user)
watched_category = Fabricate(:category)
CategoryUser.create!(user: user, category: watched_category, notification_level: CategoryUser.notification_levels[:watching])
post = create_post(category: watched_category)
tu = TopicUser.get(post.topic, user)
expect(tu.notification_level).to eq TopicUser.notification_levels[:watching]
# Now, change the topic's category
unwatched_category = Fabricate(:category)
post.topic.change_category_to_id(unwatched_category.id)
expect(TopicUser.get(post.topic, user)).to be_blank
end
end
end