FEATURE: send message when a user reaches tl1

This commit is contained in:
Jeff Wong
2018-06-22 09:51:07 -07:00
parent 6901e0e043
commit 41f76a74f8
5 changed files with 47 additions and 2 deletions

View File

@ -53,7 +53,7 @@ describe Promotion do
end
end
context "that has done the requisite things" do
context "that has not done the requisite things" do
it "does not promote the user" do
user.created_at = 1.minute.ago
stat = user.user_stat
@ -66,6 +66,32 @@ describe Promotion do
end
end
context "may send tl1 promotion messages" do
before do
stat = user.user_stat
stat.topics_entered = SiteSetting.tl1_requires_topics_entered
stat.posts_read_count = SiteSetting.tl1_requires_read_posts
stat.time_read = SiteSetting.tl1_requires_time_spent_mins * 60
end
it "sends promotion message by default" do
SiteSetting.send_tl1_welcome_message = true
Jobs.expects(:enqueue).with(
:send_system_message,
user_id: user.id, message_type: "welcome_tl1_user"
).once
@result = promotion.review
end
it "can be turned off" do
SiteSetting.send_tl1_welcome_message = false
Jobs.expects(:enqueue).with(
:send_system_message,
user_id: user.id, message_type: "welcome_tl1_user"
).never
@result = promotion.review
end
end
end
context "basic" do