FIX: Validate user email only once (#12327)

It was validated twice: once by validates_associated and once
by has_many.
This commit is contained in:
Bianca Nenciu 2021-03-10 14:49:13 +02:00 committed by GitHub
parent 990a26d14b
commit 92ad2182f5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 2 deletions

View File

@ -40,7 +40,7 @@ class User < ActiveRecord::Base
has_one :user_option, dependent: :destroy
has_one :user_avatar, dependent: :destroy
has_one :primary_email, -> { where(primary: true) }, class_name: 'UserEmail', dependent: :destroy, autosave: true
has_one :primary_email, -> { where(primary: true) }, class_name: 'UserEmail', dependent: :destroy, autosave: true, validate: false
has_one :user_stat, dependent: :destroy
has_one :user_profile, dependent: :destroy, inverse_of: :user
has_one :single_sign_on_record, dependent: :destroy

View File

@ -90,7 +90,7 @@ describe User do
user.email = 'test@gmailcom'
expect(user).to_not be_valid
expect(user.errors.messages).to include(:primary_email)
expect(user.errors.messages.keys).to contain_exactly(:primary_email)
end
end