mirror of
https://github.com/internetee/registry.git
synced 2025-05-28 09:51:03 +02:00
disallow CID for registrar code and fix double code check
This commit is contained in:
parent
c27de39a15
commit
1f504e08ea
5 changed files with 36 additions and 7 deletions
|
@ -228,6 +228,22 @@ describe Contact do
|
|||
@contact.code.should == 'FIXED:NEW-CODE'
|
||||
end
|
||||
|
||||
it 'should not allaw to use same code' do
|
||||
@contact = Fabricate.build(:contact,
|
||||
code: 'FIXED:new-code',
|
||||
auth_info: 'qwe321')
|
||||
@contact.code.should == 'FIXED:new-code' # still new record
|
||||
@contact.save.should == true
|
||||
@contact.code.should == 'FIXED:NEW-CODE'
|
||||
|
||||
@contact = Fabricate.build(:contact,
|
||||
code: 'FIXED:new-code',
|
||||
auth_info: 'qwe321')
|
||||
@contact.code.should == 'FIXED:new-code' # still new record
|
||||
@contact.valid?
|
||||
@contact.errors.full_messages.should == ["Code Contact id already exists"]
|
||||
end
|
||||
|
||||
it 'should generate a new password' do
|
||||
@contact = Fabricate.build(:contact, code: '123asd', auth_info: 'qwe321')
|
||||
@contact.auth_info.should == 'qwe321'
|
||||
|
@ -258,10 +274,10 @@ describe Contact do
|
|||
@contact.code.should_not == ''
|
||||
end
|
||||
|
||||
it 'should not allow empty spaces as code' do
|
||||
it 'should not ignore empty spaces as code and generate new one' do
|
||||
@contact = Fabricate.build(:contact, code: ' ')
|
||||
@contact.valid?
|
||||
@contact.errors.full_messages.should == ['Code is invalid']
|
||||
@contact.valid?.should == true
|
||||
@contact.code.should =~ /FIXED:..../
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue