mirror of
https://github.com/discourse/discourse.git
synced 2025-06-05 08:54:43 +08:00
BUGFIX: tracking categories was not implemented
This commit is contained in:
@ -15,6 +15,14 @@ class CategoryUser < ActiveRecord::Base
|
|||||||
TopicUser.notification_levels
|
TopicUser.notification_levels
|
||||||
end
|
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)
|
def self.auto_watch_new_topic(topic)
|
||||||
apply_default_to_topic(
|
apply_default_to_topic(
|
||||||
topic,
|
topic,
|
||||||
|
@ -27,7 +27,8 @@ class TopicUser < ActiveRecord::Base
|
|||||||
:created_post,
|
:created_post,
|
||||||
:auto_watch,
|
:auto_watch,
|
||||||
:auto_watch_category,
|
:auto_watch_category,
|
||||||
:auto_mute_category
|
:auto_mute_category,
|
||||||
|
:auto_track_category
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -781,6 +781,7 @@ en:
|
|||||||
"3_2": 'You will receive notifications because you are watching this topic.'
|
"3_2": 'You will receive notifications because you are watching this topic.'
|
||||||
"3_1": 'You will receive notifications because you created this topic.'
|
"3_1": 'You will receive notifications because you created this topic.'
|
||||||
"3": 'You will receive notifications because you are watching 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_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_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>.'
|
"2": 'You will receive notifications because you <a href="/users/{{username}}/preferences">read this topic</a>.'
|
||||||
|
@ -40,6 +40,7 @@ class TopicCreator
|
|||||||
end
|
end
|
||||||
|
|
||||||
CategoryUser.auto_watch_new_topic(@topic)
|
CategoryUser.auto_watch_new_topic(@topic)
|
||||||
|
CategoryUser.auto_track_new_topic(@topic)
|
||||||
end
|
end
|
||||||
|
|
||||||
def setup_topic_params
|
def setup_topic_params
|
||||||
|
@ -31,15 +31,24 @@ describe CategoryUser do
|
|||||||
it 'should operate correctly' do
|
it 'should operate correctly' do
|
||||||
watched_category = Fabricate(:category)
|
watched_category = Fabricate(:category)
|
||||||
muted_category = Fabricate(:category)
|
muted_category = Fabricate(:category)
|
||||||
|
tracked_category = Fabricate(:category)
|
||||||
|
|
||||||
user = Fabricate(:user)
|
user = Fabricate(:user)
|
||||||
|
|
||||||
CategoryUser.create!(user: user, category: watched_category, notification_level: CategoryUser.notification_levels[:watching])
|
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: 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)
|
watched_post = create_post(category: watched_category)
|
||||||
muted_post = create_post(category: muted_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: 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 = TopicUser.get(muted_post.topic, user)
|
||||||
tu.notification_level.should == TopicUser.notification_levels[:muted]
|
tu.notification_level.should == TopicUser.notification_levels[:muted]
|
||||||
|
Reference in New Issue
Block a user