mirror of
https://github.com/internetee/registry.git
synced 2025-05-18 02:09:39 +02:00
Merge branch 'master' of github.com:internetee/registry
This commit is contained in:
commit
1b3f27e01d
4 changed files with 25 additions and 7 deletions
|
@ -18,12 +18,13 @@ class Contact < ActiveRecord::Base
|
||||||
|
|
||||||
accepts_nested_attributes_for :address, :disclosure
|
accepts_nested_attributes_for :address, :disclosure
|
||||||
|
|
||||||
validates :name, :phone, :email, :ident, :address, :registrar, presence: true
|
validates :name, :phone, :email, :ident, :address, :registrar, :ident_type, presence: true
|
||||||
|
|
||||||
validate :ident_must_be_valid
|
|
||||||
|
|
||||||
validates :phone, format: /\+[0-9]{1,3}\.[0-9]{1,14}?/ # /\+\d{3}\.\d+/
|
validates :phone, format: /\+[0-9]{1,3}\.[0-9]{1,14}?/ # /\+\d{3}\.\d+/
|
||||||
validates :email, format: /@/
|
validates :email, format: /@/
|
||||||
|
validates :ident, format: /\d{4}-\d{2}-\d{2}/, if: proc { |c| c.ident_type == 'birthday' }
|
||||||
|
|
||||||
|
validate :ident_must_be_valid
|
||||||
|
|
||||||
validates :code, uniqueness: { message: :epp_id_taken }
|
validates :code, uniqueness: { message: :epp_id_taken }
|
||||||
|
|
||||||
|
@ -135,7 +136,8 @@ class Contact < ActiveRecord::Base
|
||||||
],
|
],
|
||||||
'2005' => [ # Value syntax error
|
'2005' => [ # Value syntax error
|
||||||
[:phone, :invalid],
|
[:phone, :invalid],
|
||||||
[:email, :invalid]
|
[:email, :invalid],
|
||||||
|
[:ident, :invalid]
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
|
|
||||||
# rbenv support
|
# rbenv support
|
||||||
rbenv = 'export PATH="$HOME/.rbenv/bin:$PATH";eval "$(rbenv init -)";'
|
rbenv = 'export PATH="$HOME/.rbenv/bin:$PATH";eval "$(rbenv init -)";'
|
||||||
path = Whenever.path.sub(%r(\/releases\/.*), '/current')
|
path = Whenever.path.sub(%r{\/releases\/.*}, '/current')
|
||||||
set :job_template, "/bin/bash -l -c '#{rbenv} :job'"
|
set :job_template, "/bin/bash -l -c '#{rbenv} :job'"
|
||||||
job_type :runner, "cd #{path} && bin/rails r -e :environment \":task\" :output"
|
job_type :runner, "cd #{path} && bin/rails r -e :environment \":task\" :output"
|
||||||
|
|
||||||
|
|
|
@ -58,7 +58,7 @@ describe 'EPP Contact', epp: true do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'successfully saves ident type' do
|
it 'successfully saves ident type' do
|
||||||
xml = { ident: { value: '37605030299', attrs: { type: 'birthday' } } }
|
xml = { ident: { value: '1990-22-12', attrs: { type: 'birthday' } } }
|
||||||
epp_request(create_contact_xml(xml), :xml)
|
epp_request(create_contact_xml(xml), :xml)
|
||||||
expect(Contact.last.ident_type).to eq('birthday')
|
expect(Contact.last.ident_type).to eq('birthday')
|
||||||
end
|
end
|
||||||
|
|
|
@ -17,6 +17,21 @@ describe Contact do
|
||||||
expect(@contact.valid?).to be false
|
expect(@contact.valid?).to be false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'validates birthday' do
|
||||||
|
invalid = [ '123' '12/12/2012', 'aaaa', '12/12/12', '02-11-1999' ]
|
||||||
|
invalid.each do |date|
|
||||||
|
expect(Fabricate.build(:contact, ident_type: 'birthday', ident: date).valid?).to be false
|
||||||
|
end
|
||||||
|
valid = [ '2012-12-11', '1990-02-16' ]
|
||||||
|
valid.each do |date|
|
||||||
|
expect(Fabricate.build(:contact, ident_type: 'birthday', ident: date).valid?).to be true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'doesn\'t validate ico' do
|
||||||
|
expect(Fabricate.build(:contact, ident_type: 'ico', ident: '12312adsadwe').valid?).to be true
|
||||||
|
end
|
||||||
|
|
||||||
it 'should return missing parameter error messages' do
|
it 'should return missing parameter error messages' do
|
||||||
@contact = Contact.new
|
@contact = Contact.new
|
||||||
expect(@contact.valid?).to eq false
|
expect(@contact.valid?).to eq false
|
||||||
|
@ -27,7 +42,8 @@ describe Contact do
|
||||||
email: ['Required parameter missing - email', 'Email is invalid'],
|
email: ['Required parameter missing - email', 'Email is invalid'],
|
||||||
ident: ['Required parameter missing - ident'],
|
ident: ['Required parameter missing - ident'],
|
||||||
address: ['is missing'],
|
address: ['is missing'],
|
||||||
registrar: ['is missing']
|
registrar: ['is missing'],
|
||||||
|
ident_type: ['is missing']
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue