diff --git a/app/models/user.rb b/app/models/user.rb index 0d1f61b1237..d8cbdc3fb7d 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -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 diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index 77bf74e7012..fce64e2cdea 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -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