FIX: granting beginners badges when user skipped new user tips (PR #12771)

Unfortunately, badges for beginners weren’t skipping when a user chose to skip “new user tips”. We had a check here. But the code that was actually granting badges in most cases is here and written in SQL.

This PR adds a field for_beginners to Badge and fixes the problem.


You should be using the ids from here otherwise it probably won’t work if they changed the name of the badge or if they’re using a different locale :wink:

You could do less work for the database by using

expect {
}.to_not change { UserBadge.count }

In addition to this migration I think you need to set up these beginner badges in the badge fixture

I am fairly sure this is run when the Discourse site is first set up

My main concern is why do we need to add a new column when we have badge_grouping_id and BadgeGrouping::GettingStarted already?

Actually now that I think about it, is there any reason you even need a new column? Can’t you just rely on the badge_grouping_id of BadgeGrouping::GettingStarted which is already set up?

Unfortunately, we can’t rely on the badge_grouping_id only.

Now we are skipping all the badges from the Getting Started group excluding the New User of the Month badge plus the Welcome badge (which is in the Community group).

And we want to be able to skip certain badges without moving them between groups.

Ah yes makes sense, I guess the fixtures just need to be updated?

Yeah, I’ve updated the fixture.