FIX: do not send tl1 welcome message when a user has the basic user badge

This commit is contained in:
Jeff Wong 2018-09-19 12:52:45 -07:00
parent 469a2c36ed
commit d5442fbf08
2 changed files with 12 additions and 1 deletions

View File

@ -24,7 +24,7 @@ class Promotion
def review_tl0
if Promotion.tl1_met?(@user) && change_trust_level!(TrustLevel[1])
@user.enqueue_member_welcome_message
@user.enqueue_member_welcome_message unless @user.badges.where(id: Badge::BasicUser).count > 0
return true
end
false

View File

@ -82,6 +82,17 @@ describe Promotion do
expect(job["args"][0]["message_type"]).to eq("welcome_tl1_user")
end
it "does not not send when the user already has the tl1 badge when recalculcating" do
SiteSetting.send_tl1_welcome_message = true
BadgeGranter.grant(Badge.find(1), user)
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
Promotion.recalculate(user)
expect(Jobs::SendSystemMessage.jobs.length).to eq(0)
end
it "can be turned off" do
SiteSetting.send_tl1_welcome_message = false
@result = promotion.review