vrfs152: relaxed requirement for an email address

This commit is contained in:
Jonathan Kolyer 2014-01-15 03:56:46 -06:00
parent 84360ea642
commit 8f7a959a9e
3 changed files with 11 additions and 4 deletions

View File

@ -14,13 +14,14 @@ module JamRuby
belongs_to :sender , :inverse_of => :invited_users, :class_name => "JamRuby::User", :foreign_key => "sender_id"
# who is the invitation sent to?
validates :email, :presence => true, format: {with: VALID_EMAIL_REGEX}
validates :email, format: {with: VALID_EMAIL_REGEX}, :if => lambda { |iu| iu.email.present? }
validates :autofriend, :inclusion => {:in => [nil, true, false]}
validates :invitation_code, :presence => true
validates :note, length: {maximum: 400}, no_profanity: true # 400 == arbitrary.
validate :valid_personalized_invitation
validate :not_accepted_twice
# validate :not_accepted_twice
validate :not_accepted_twice, :if => lambda { |iu| iu.email }
validate :can_invite?
after_save :track_user_progression

View File

@ -8,7 +8,7 @@ module JamRuby
InvitedUserMailer.welcome_betauser(invited_user).deliver
else
InvitedUserMailer.friend_invitation(invited_user).deliver
end
end if invited_user.email.present?
end
end
end
end

View File

@ -104,4 +104,10 @@ describe InvitedUser do
invited_user.valid?.should be_false
end
it 'accepts empty emails' do
user1 = FactoryGirl.create(:user)
invited_user = FactoryGirl.create(:invited_user, :sender => user1, :email => '')
expect(invited_user.valid?).to eq(true)
end
end