Corrected with rubocop cop 'Rails/Validation'.

This commit is contained in:
Thorsten Eckel 2015-05-05 15:33:39 +02:00
parent 3cefc118c9
commit 9cd4bb748a
2 changed files with 7 additions and 8 deletions

View file

@ -266,8 +266,6 @@ Style/InfiniteLoop:
Enabled: false Enabled: false
Lint/AmbiguousRegexpLiteral: Lint/AmbiguousRegexpLiteral:
Enabled: false Enabled: false
Rails/Validation:
Enabled: false
Lint/Eval: Lint/Eval:
Enabled: false Enabled: false
Style/ModuleFunction: Style/ModuleFunction:

View file

@ -1,12 +1,13 @@
# Copyright (C) 2012-2014 Zammad Foundation, http://zammad-foundation.org/ # Copyright (C) 2012-2014 Zammad Foundation, http://zammad-foundation.org/
class Authorization < ApplicationModel class Authorization < ApplicationModel
belongs_to :user belongs_to :user
after_create :delete_user_cache after_create :delete_user_cache
after_update :delete_user_cache after_update :delete_user_cache
after_destroy :delete_user_cache after_destroy :delete_user_cache
validates_presence_of :user_id, :uid, :provider validates :user_id, presence: true
validates_uniqueness_of :uid, scope: :provider validates :uid, presence: true, uniqueness: { scope: :provider }
validates :provider, presence: true
def self.find_from_hash(hash) def self.find_from_hash(hash)
auth = Authorization.where( provider: hash['provider'], uid: hash['uid'] ).first auth = Authorization.where( provider: hash['provider'], uid: hash['uid'] ).first