From 9cd4bb748aa53008e05314ea4c10a730c7aa8229 Mon Sep 17 00:00:00 2001 From: Thorsten Eckel Date: Tue, 5 May 2015 15:33:39 +0200 Subject: [PATCH] Corrected with rubocop cop 'Rails/Validation'. --- .rubocop.yml | 2 -- app/models/authorization.rb | 13 +++++++------ 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index a422d8f6a..51d21cc87 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -266,8 +266,6 @@ Style/InfiniteLoop: Enabled: false Lint/AmbiguousRegexpLiteral: Enabled: false -Rails/Validation: - Enabled: false Lint/Eval: Enabled: false Style/ModuleFunction: diff --git a/app/models/authorization.rb b/app/models/authorization.rb index 95bcfde84..53c5e13a2 100644 --- a/app/models/authorization.rb +++ b/app/models/authorization.rb @@ -1,12 +1,13 @@ # Copyright (C) 2012-2014 Zammad Foundation, http://zammad-foundation.org/ class Authorization < ApplicationModel - belongs_to :user - after_create :delete_user_cache - after_update :delete_user_cache - after_destroy :delete_user_cache - validates_presence_of :user_id, :uid, :provider - validates_uniqueness_of :uid, scope: :provider + belongs_to :user + after_create :delete_user_cache + after_update :delete_user_cache + after_destroy :delete_user_cache + validates :user_id, presence: true + validates :uid, presence: true, uniqueness: { scope: :provider } + validates :provider, presence: true def self.find_from_hash(hash) auth = Authorization.where( provider: hash['provider'], uid: hash['uid'] ).first