mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-27 09:36:19 -05:00
FIX: all badges got revoked due to ensure consistency query
This commit is contained in:
parent
480e8d0dc7
commit
aae835a42f
2 changed files with 3 additions and 2 deletions
|
@ -378,7 +378,7 @@ SQL
|
|||
DELETE FROM user_badges
|
||||
USING user_badges ub
|
||||
LEFT JOIN users u ON u.id = ub.user_id
|
||||
WHERE u.id IS NULL
|
||||
WHERE u.id IS NULL AND user_badges.id = ub.id
|
||||
SQL
|
||||
|
||||
Badge.find_each(&:reset_grant_count!)
|
||||
|
|
|
@ -49,11 +49,12 @@ describe Badge do
|
|||
b.save
|
||||
|
||||
UserBadge.create!(user_id: -100, badge_id: b.id, granted_at: 1.minute.ago, granted_by_id: -1)
|
||||
UserBadge.create!(user_id: User.first.id, badge_id: b.id, granted_at: 1.minute.ago, granted_by_id: -1)
|
||||
|
||||
Badge.ensure_consistency!
|
||||
|
||||
b.reload
|
||||
expect(b.grant_count).to eq(0)
|
||||
expect(b.grant_count).to eq(1)
|
||||
end
|
||||
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue