mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-27 09:36:19 -05:00
BUGFIX: tracking categories was not implemented
This commit is contained in:
parent
7cba724fdb
commit
0979e7b9af
5 changed files with 21 additions and 1 deletions
|
@ -15,6 +15,14 @@ class CategoryUser < ActiveRecord::Base
|
|||
TopicUser.notification_levels
|
||||
end
|
||||
|
||||
def self.auto_track_new_topic(topic)
|
||||
apply_default_to_topic(
|
||||
topic,
|
||||
TopicUser.notification_levels[:tracking],
|
||||
TopicUser.notification_reasons[:auto_track_category]
|
||||
)
|
||||
end
|
||||
|
||||
def self.auto_watch_new_topic(topic)
|
||||
apply_default_to_topic(
|
||||
topic,
|
||||
|
|
|
@ -27,7 +27,8 @@ class TopicUser < ActiveRecord::Base
|
|||
:created_post,
|
||||
:auto_watch,
|
||||
:auto_watch_category,
|
||||
:auto_mute_category
|
||||
:auto_mute_category,
|
||||
:auto_track_category
|
||||
)
|
||||
end
|
||||
|
||||
|
|
|
@ -781,6 +781,7 @@ en:
|
|||
"3_2": 'You will receive notifications because you are watching this topic.'
|
||||
"3_1": 'You will receive notifications because you created this topic.'
|
||||
"3": 'You will receive notifications because you are watching this topic.'
|
||||
"2_8": 'You will receive notifications because you are tracking this category.'
|
||||
"2_4": 'You will receive notifications because you posted a reply to this topic.'
|
||||
"2_2": 'You will receive notifications because you are tracking this topic.'
|
||||
"2": 'You will receive notifications because you <a href="/users/{{username}}/preferences">read this topic</a>.'
|
||||
|
|
|
@ -40,6 +40,7 @@ class TopicCreator
|
|||
end
|
||||
|
||||
CategoryUser.auto_watch_new_topic(@topic)
|
||||
CategoryUser.auto_track_new_topic(@topic)
|
||||
end
|
||||
|
||||
def setup_topic_params
|
||||
|
|
|
@ -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]
|
||||
|
|
Loading…
Reference in a new issue