A platform for community discussion. Free, open, simple.
FIX: check if BasicBadge is enabled for TL1 welcome message (#13983)
Krzysztof Kotlarek195f7346bac0
diff --git a/lib/promotion.rb b/lib/promotion.rbindex 286494f182a..5ac5ee519da 100644--- a/lib/promotion.rb+++ b/lib/promotion.rb@@ -26,7 +26,9 @@ class Promotiondef review_tl0if Promotion.tl1_met?(@user) && change_trust_level!(TrustLevel[1])- @user.enqueue_member_welcome_message unless @user.badges.where(id: Badge::BasicUser).count > 0+ if Badge.exists?(id: Badge::BasicUser, enabled: true) && [email protected]?(id: Badge::BasicUser)+ @user.enqueue_member_welcome_message+ endreturn trueendfalsediff --git a/spec/components/promotion_spec.rb b/spec/components/promotion_spec.rbindex ca61fe3568e..abf4c330905 100644--- a/spec/components/promotion_spec.rb+++ b/spec/components/promotion_spec.rb@@ -95,6 +95,17 @@ describe Promotion doexpect(Jobs::SendSystemMessage.jobs.length).to eq(0)end+ it "does not not send when the tl1 badge is disabled" do+ SiteSetting.send_tl1_welcome_message = true+ Badge.find(1).update!(enabled: false)+ 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" doSiteSetting.send_tl1_welcome_message = false@result = promotion.review