mirror of
https://github.com/discourse/discourse.git
synced 2024-11-23 06:04:11 +08:00
FIX: Update featured badge ranking when mass-awarding badges
Follow-up to cff6e941de
This commit is contained in:
parent
cff6e941de
commit
4fdfc2665d
|
@ -28,6 +28,8 @@ class BadgeGranter
|
||||||
user_id: user.id,
|
user_id: user.id,
|
||||||
badge_id: badge.id
|
badge_id: badge.id
|
||||||
)
|
)
|
||||||
|
|
||||||
|
UserBadge.update_featured_ranks!(user.id)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -28,5 +28,16 @@ describe Jobs::MassAwardBadge do
|
||||||
expect(Notification.exists?(user: user)).to eq(true)
|
expect(Notification.exists?(user: user)).to eq(true)
|
||||||
expect(UserBadge.where.not(notification_id: nil).exists?(user: user, badge: badge)).to eq(true)
|
expect(UserBadge.where.not(notification_id: nil).exists?(user: user, badge: badge)).to eq(true)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'updates badge ranks correctly' do
|
||||||
|
user_2 = Fabricate(:user)
|
||||||
|
|
||||||
|
UserBadge.create!(badge_id: Badge::Member, user: user, granted_by: Discourse.system_user, granted_at: Time.now)
|
||||||
|
|
||||||
|
subject.execute(user_emails: [user.email, user_2.email], badge_id: badge.id)
|
||||||
|
|
||||||
|
expect(UserBadge.find_by(user: user, badge: badge).featured_rank).to eq(2)
|
||||||
|
expect(UserBadge.find_by(user: user_2, badge: badge).featured_rank).to eq(1)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue
Block a user