Fix all the errors to get our tests green on Rails 5.1.

This commit is contained in:
Guo Xiang Tan
2017-08-31 12:06:56 +08:00
parent 898ee93547
commit 77d4c4d8dc
989 changed files with 5114 additions and 3117 deletions

View File

@ -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