FIX: Always validate presence of user's primary_email.

This commit is contained in:
Guo Xiang Tan 2017-07-31 11:45:18 +09:00
parent b059a0f789
commit 24e0e000b9
2 changed files with 2 additions and 1 deletions

View File

@ -81,7 +81,7 @@ class User < ActiveRecord::Base
validate :password_validator
validates :name, user_full_name: true, if: :name_changed?, length: { maximum: 255 }
validates :ip_address, allowed_ip_address: { on: :create, message: :signup_not_allowed }
validates :primary_email, presence: true, if: :should_validate_primary_email?
validates :primary_email, presence: true
validates_associated :primary_email, if: :should_validate_primary_email?
after_initialize :add_trust_level

View File

@ -5,6 +5,7 @@ describe User do
context 'validations' do
it { is_expected.to validate_presence_of :username }
it { is_expected.to validate_presence_of :primary_email }
describe 'emails' do
let(:user) { Fabricate.build(:user) }