Skip to content

A platform for community discussion. Free, open, simple.

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

Jeff Wongd5442fbf08b1
diff --git a/lib/promotion.rb b/lib/promotion.rb
index c6527b47dea..84b56783d44 100644
--- a/lib/promotion.rb
+++ b/lib/promotion.rb
@@ -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
diff --git a/spec/components/promotion_spec.rb b/spec/components/promotion_spec.rb
index ae69602979f..6191c2c5d89 100644
--- a/spec/components/promotion_spec.rb
+++ b/spec/components/promotion_spec.rb
@@ -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