FIX: Don't skip the new user badge (#10743)

FIX: Don’t skip the new user badge (#10743)

The NewUserOfTheMonth badge is part of the Badges::GettingStarted group. This group is skipped in BadgeGranter if the user skips the new user tips. However, the NewUserOfTheMonth badge granter job does not account for this. Instead, it notifies the user they’ve received the badge even if they did not.

This commit introduces a simple fix to allow granting of this badge even to users who skipped the new user tips.

diff --git a/app/services/badge_granter.rb b/app/services/badge_granter.rb
index 1e1059b..ad9d310 100644
--- a/app/services/badge_granter.rb
+++ b/app/services/badge_granter.rb
@@ -45,7 +45,7 @@ class BadgeGranter
   def grant
     return if @granted_by && !
     return unless @badge.enabled?
-    return if @badge.badge_grouping_id == BadgeGrouping::GettingStarted && @user.user_option.skip_new_user_tips
+    return if @badge.badge_grouping_id == BadgeGrouping::GettingStarted && != Badge::NewUserOfTheMonth && @user.user_option.skip_new_user_tips
     find_by = { badge_id:, user_id: }
diff --git a/spec/services/badge_granter_spec.rb b/spec/services/badge_granter_spec.rb
index e683c81..310a993 100644
--- a/spec/services/badge_granter_spec.rb
+++ b/spec/services/badge_granter_spec.rb
@@ -225,6 +225,15 @@ describe BadgeGranter do
       expect(user_badge).to eq(nil)
+    it "grants the New User of the Month badge when user skipped new user tips" do
+      freeze_time
+      user.user_option.update!(skip_new_user_tips: true)
+      badge = Badge.find(Badge::NewUserOfTheMonth)
+      user_badge = BadgeGranter.grant(badge, user, created_at: 1.year.ago)
+      expect(user_badge).to be_present
+    end
     it 'grants multiple badges' do
       badge = Fabricate(:badge, multiple_grant: true)
       user_badge = BadgeGranter.grant(badge, user)

GitHub sha: 82a18f12

This commit appears in #10743 which was approved by markvanlan. It was merged by justindirose.

This commit has been mentioned on Discourse Meta. There might be relevant details there:

This commit has been mentioned on Discourse Meta. There might be relevant details there: