mirror of
https://github.com/discourse/discourse.git
synced 2024-11-23 19:37:55 +08:00
Merge pull request #2479 from vikhyat/badge-system
Badge system updates
This commit is contained in:
commit
386a45aab7
|
@ -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,
|
||||
|
|
|
@ -1933,10 +1933,10 @@ en:
|
|||
description: Received a like.
|
||||
nice_post:
|
||||
name: Nice Post
|
||||
description: Received 10 likes on a post.
|
||||
description: Received 10 likes on a post. This badge can be granted multiple times.
|
||||
good_post:
|
||||
name: Good Post
|
||||
description: Received 25 likes on a post.
|
||||
description: Received 25 likes on a post. This badge can be granted multiple times.
|
||||
great_post:
|
||||
name: Great Post
|
||||
description: Received 100 likes on a post.
|
||||
description: Received 100 likes on a post. This badge can be granted multiple times.
|
||||
|
|
|
@ -90,7 +90,9 @@ describe BadgeGranter do
|
|||
# Nice post badge
|
||||
post.update_attributes like_count: 10
|
||||
BadgeGranter.update_badges(action: :post_like, post_id: post.id)
|
||||
BadgeGranter.update_badges(action: :post_like, post_id: post.id)
|
||||
UserBadge.find_by(user_id: user.id, badge_id: 6).should_not be_nil
|
||||
UserBadge.where(user_id: user.id, badge_id: 6).count.should == 1
|
||||
# Good post badge
|
||||
post.update_attributes like_count: 25
|
||||
BadgeGranter.update_badges(action: :post_like, post_id: post.id)
|
||||
|
|
Loading…
Reference in New Issue
Block a user