summaryrefslogtreecommitdiff
path: root/app/models/identity.rb
diff options
context:
space:
mode:
authorYorick Peterse <yorickpeterse@gmail.com>2018-11-12 14:14:13 +0100
committerYorick Peterse <yorickpeterse@gmail.com>2018-11-12 14:14:13 +0100
commit9d5f921ab0266bf705ca4402335e347b43c75557 (patch)
treef8234694660731a6899c3b27508856e73facf69c /app/models/identity.rb
parent9aa705dd38045b1121557faddf789ce8e114fc7d (diff)
downloadgitlab-ce-9d5f921ab0266bf705ca4402335e347b43c75557.tar.gz
Move Identity.uniqueness_scope to a modulerefactor-reference-regexes-and-identity-scopes
Moving this method to a separate module looks a bit odd, but it allows for EE to extend the method without also having to redefine a variety of validation rules.
Diffstat (limited to 'app/models/identity.rb')
-rw-r--r--app/models/identity.rb8
1 files changed, 2 insertions, 6 deletions
diff --git a/app/models/identity.rb b/app/models/identity.rb
index f5a13dbd6f2..d63dd432426 100644
--- a/app/models/identity.rb
+++ b/app/models/identity.rb
@@ -1,18 +1,14 @@
# frozen_string_literal: true
class Identity < ActiveRecord::Base
- def self.uniqueness_scope
- :provider
- end
-
include Sortable
include CaseSensitivity
belongs_to :user
validates :provider, presence: true
- validates :extern_uid, allow_blank: true, uniqueness: { scope: uniqueness_scope, case_sensitive: false }
- validates :user_id, uniqueness: { scope: uniqueness_scope }
+ validates :extern_uid, allow_blank: true, uniqueness: { scope: UniquenessScopes.scopes, case_sensitive: false }
+ validates :user_id, uniqueness: { scope: UniquenessScopes.scopes }
before_save :ensure_normalized_extern_uid, if: :extern_uid_changed?
after_destroy :clear_user_synced_attributes, if: :user_synced_attributes_metadata_from_provider?