From ebe232da4717ceca25f4cad30daafcb21c8f2dc4 Mon Sep 17 00:00:00 2001 From: Robin Ward Date: Mon, 3 Apr 2017 16:52:31 -0400 Subject: [PATCH] Weigh staff votes more for New User of the Month badges --- .../grant_new_user_of_the_month_badges.rb | 1 + ...grant_new_user_of_the_month_badges_spec.rb | 24 ++++++++++++------- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/app/jobs/scheduled/grant_new_user_of_the_month_badges.rb b/app/jobs/scheduled/grant_new_user_of_the_month_badges.rb index 554710d7ffc..7842175fa37 100644 --- a/app/jobs/scheduled/grant_new_user_of_the_month_badges.rb +++ b/app/jobs/scheduled/grant_new_user_of_the_month_badges.rb @@ -40,6 +40,7 @@ module Jobs SUM(CASE WHEN pa.id IS NOT NULL THEN CASE + WHEN liked_by.admin OR liked_by.moderator THEN 2.0 WHEN liked_by.trust_level = 0 THEN 0.1 WHEN liked_by.trust_level = 1 THEN 0.25 WHEN liked_by.trust_level = 2 THEN 1.0 diff --git a/spec/jobs/grant_new_user_of_the_month_badges_spec.rb b/spec/jobs/grant_new_user_of_the_month_badges_spec.rb index 414f7be0ac5..748a8343836 100644 --- a/spec/jobs/grant_new_user_of_the_month_badges_spec.rb +++ b/spec/jobs/grant_new_user_of_the_month_badges_spec.rb @@ -95,18 +95,26 @@ describe Jobs::GrantNewUserOfTheMonthBadges do p = Fabricate(:post, user: user) Fabricate(:post, user: user) - new_user = Fabricate(:user, created_at: 2.days.ago) - med_user = Fabricate(:user, created_at: 3.weeks.ago) - old_user = Fabricate(:user, created_at: 6.months.ago) + u0 = Fabricate(:user, trust_level: 0) + u1 = Fabricate(:user, trust_level: 1) + u2 = Fabricate(:user, trust_level: 2) + u3 = Fabricate(:user, trust_level: 3) + u4 = Fabricate(:user, trust_level: 4) + um = Fabricate(:user, trust_level: 3, moderator: true) + ua = Fabricate(:user, trust_level: 0, admin: true) - PostAction.act(new_user, p, PostActionType.types[:like]) - PostAction.act(med_user, p, PostActionType.types[:like]) - PostAction.act(old_user, p, PostActionType.types[:like]) - expect(granter.scores[user.id]).to eq(0.375) + PostAction.act(u0, p, PostActionType.types[:like]) + PostAction.act(u1, p, PostActionType.types[:like]) + PostAction.act(u2, p, PostActionType.types[:like]) + PostAction.act(u3, p, PostActionType.types[:like]) + PostAction.act(u4, p, PostActionType.types[:like]) + PostAction.act(um, p, PostActionType.types[:like]) + PostAction.act(ua, p, PostActionType.types[:like]) + expect(granter.scores[user.id]).to eq(4.425) # It goes down the more they post Fabricate(:post, user: user) - expect(granter.scores[user.id]).to eq(0.25) + expect(granter.scores[user.id]).to eq(2.95) end it "is limited to two accounts" do