Validate contact and invoice emails when they change #2745

This commit is contained in:
Priit Tark 2015-08-06 13:21:15 +03:00
parent c482a3e46d
commit 6ca53f946a
7 changed files with 43 additions and 2 deletions

View file

@ -133,6 +133,13 @@ describe 'EPP Contact', epp: true do
cr_date.text.in_time_zone.utc.should be_within(5).of(Time.zone.now)
end
it 'should return email issue' do
response = create_request(email: { value: 'not@valid' })
response[:msg].should == 'Email is invalid [email]'
response[:result_code].should == '2005'
end
it 'should add registrar prefix for code when missing' do
response = create_request({ id: { value: 'abc12345' } })
response[:msg].should == 'Command completed successfully'
@ -397,6 +404,18 @@ describe 'EPP Contact', epp: true do
response[:results][1][:result_code].should == '2005'
end
it 'should return email issue' do
response = update_request({
id: { value: 'FIRST0:SH8013' },
chg: {
email: { value: 'legacy@wrong' }
}
})
response[:msg].should == 'Email is invalid [email]'
response[:result_code].should == '2005'
end
it 'should not update code with custom string' do
response = update_request(
{

View file

@ -109,6 +109,12 @@ describe Contact do
it 'should have no related domain descriptions' do
@contact.related_domain_descriptions.should == {}
end
it 'should fully validate email syntax for new records' do
@contact.email = 'not@correct'
@contact.valid?
@contact.errors[:email].should == ['Email is invalid']
end
end
context 'with valid attributes' do
@ -247,6 +253,14 @@ describe Contact do
contact = @domain.contacts.first
contact.related_domain_descriptions.should == { "#{@domain.name}" => [:admin] }
end
it 'should fully validate email syntax for old records' do
old = @contact.email
@contact.email = 'legacy@support-not-correct'
@contact.valid?
@contact.errors[:email].should == ['Email is invalid']
@contact.email = old
end
end
context 'as birthday' do