mirror of
https://github.com/discourse/discourse.git
synced 2025-06-01 08:49:03 +08:00
Fix all the errors to get our tests green on Rails 5.1.
This commit is contained in:
@ -5,7 +5,11 @@ class UserBadge < ActiveRecord::Base
|
||||
belongs_to :notification, dependent: :destroy
|
||||
belongs_to :post
|
||||
|
||||
validates :badge_id, presence: true, uniqueness: { scope: :user_id }, if: 'badge.single_grant?'
|
||||
validates :badge_id,
|
||||
presence: true,
|
||||
uniqueness: { scope: :user_id },
|
||||
if: :single_grant_badge?
|
||||
|
||||
validates :user_id, presence: true
|
||||
validates :granted_at, presence: true
|
||||
validates :granted_by, presence: true
|
||||
@ -19,6 +23,12 @@ class UserBadge < ActiveRecord::Base
|
||||
Badge.decrement_counter 'grant_count', self.badge_id
|
||||
DiscourseEvent.trigger(:user_badge_removed, self.badge_id, self.user_id)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def single_grant_badge?
|
||||
self.badge.single_grant?
|
||||
end
|
||||
end
|
||||
|
||||
# == Schema Information
|
||||
|
Reference in New Issue
Block a user