Don't grant multiple_grant badges multiple times for the same post.

This commit is contained in:
Vikhyat Korrapati
2014-06-28 00:32:09 +05:30
parent b6226ab339
commit 23983efeea
2 changed files with 3 additions and 1 deletions

View File

@@ -15,7 +15,7 @@ class BadgeGranter
user_badge = UserBadge.find_by(badge_id: @badge.id, user_id: @user.id, post_id: @post_id)
if user_badge.nil? || @badge.multiple_grant?
if user_badge.nil? || (@badge.multiple_grant? && @post_id.nil?)
UserBadge.transaction do
user_badge = UserBadge.create!(badge: @badge, user: @user,
granted_by: @granted_by,