FEATURE: proper mailing list mode

once enable_mailing_list_mode is enabled any user can elect
to get every post via email unless they opt out of category or topic
This commit is contained in:
Sam
2014-02-07 11:06:35 +11:00
parent 3a1c5ed39d
commit 227873df78
23 changed files with 134 additions and 68 deletions

View File

@@ -268,21 +268,28 @@ describe TopicUser do
tu.seen_post_count.should == 2
end
describe "auto_watch_new_topic" do
describe "mailing_list_mode" do
it "will receive email notification for every topic" do
SiteSetting.stubs(:enable_mailing_list_mode).returns(true)
it "auto watches topics when called" do
user1 = Fabricate(:user)
user2 = Fabricate(:user, watch_new_topics: true)
user3 = Fabricate(:user, watch_new_topics: true)
TopicUser.auto_watch_new_topic(topic.id)
user2 = Fabricate(:user, mailing_list_mode: true)
post = create_post
user3 = Fabricate(:user, mailing_list_mode: true)
create_post(topic_id: post.topic_id)
TopicUser.get(topic, user1).should == nil
# mails posts from earlier topics
tu = TopicUser.where(user_id: user3.id, topic_id: post.topic_id).first
tu.last_emailed_post_number.should == 2
tu = TopicUser.get(topic, user2)
tu.notification_level.should == TopicUser.notification_levels[:watching]
tu.notifications_reason_id.should == TopicUser.notification_reasons[:auto_watch]
# mails nothing to random users
tu = TopicUser.where(user_id: user1.id, topic_id: post.topic_id).first
tu.should be_nil
TopicUser.get(topic, user3).notification_level.should == TopicUser.notification_levels[:watching]
# mails other user
tu = TopicUser.where(user_id: user2.id, topic_id: post.topic_id).first
tu.last_emailed_post_number.should == 2
end
end