Added ident country code and improved other ident things

This commit is contained in:
Priit Tark 2015-02-18 15:26:51 +02:00
parent e9b77c5b0f
commit 44f11de5c8
13 changed files with 117 additions and 66 deletions

View file

@ -44,7 +44,7 @@ describe 'EPP Contact', epp: true do
},
voice: { value: '+372.1234567' },
email: { value: 'test@example.example' },
ident: { value: '37605030299', attrs: { type: 'priv' } }
ident: { value: '37605030299', attrs: { type: 'priv', cc: 'EE' } }
}
create_xml = @epp_xml.create(defaults.deep_merge(overwrites), @legal_document)
epp_plain_request(create_xml, :xml)
@ -331,12 +331,6 @@ describe 'EPP Contact', epp: true do
end
context 'info command' do
before :all do
@registrar1_contact = Fabricate(
:contact, code: 'info-4444', registrar: @registrar1,
name: 'Johnny Awesome', address: Fabricate(:address))
end
def info_request(overwrites = {})
defaults = {
id: { value: @contact.code },
@ -363,6 +357,10 @@ describe 'EPP Contact', epp: true do
end
it 'return info about contact' do
@registrar1_contact = Fabricate(
:contact, code: 'info-4444', registrar: @registrar1,
name: 'Johnny Awesome', address: Fabricate(:address))
response = info_request({ id: { value: @registrar1_contact.code } })
response[:msg].should == 'Command completed successfully'
response[:result_code].should == '1000'

View file

@ -16,7 +16,7 @@ describe 'EPP Domain', epp: true do
Fabricate(:contact, code: 'citizen_1234')
Fabricate(:contact, code: 'sh8013')
Fabricate(:contact, code: 'sh801333')
Fabricate(:contact, code: 'juridical_1234', ident_type: 'ico')
Fabricate(:contact, code: 'juridical_1234', ident_type: 'bic')
Fabricate(:reserved_domain)
@uniq_no = proc { @i ||= 0; @i += 1 }
@ -669,8 +669,8 @@ describe 'EPP Domain', epp: true do
})
response = epp_plain_request(xml, :xml)
response[:result_code].should == '2004'
response[:msg].should == 'Admin contacts count must be between 1-10'
response[:result_code].should == '2004'
response[:clTRID].should == 'ABC-12345'
Domain.count.should == domain_count
@ -686,8 +686,8 @@ describe 'EPP Domain', epp: true do
})
response = epp_plain_request(xml, :xml)
response[:result_code].should == '2306'
response[:msg].should == 'Admin contact can be only citizen'
response[:result_code].should == '2306'
end
end

View file

@ -1,10 +1,11 @@
Fabricator(:contact) do
code { "sh#{Faker::Number.number(8)}" }
name { sequence(:name) { |i| "#{Faker::Name.name}#{i}" } }
phone '+372.12345678'
email Faker::Internet.email
ident '37605030299'
code { "sh#{Faker::Number.number(8)}" }
ident_type 'op'
ident_type 'priv'
ident_country_code 'EE'
auth_info 'ccds4324pok'
address
registrar { Fabricate(:registrar, name: Faker::Company.name, reg_no: Faker::Company.duns_number) }

View file

@ -52,6 +52,42 @@ describe Contact do
@contact.errors[:phone].should == ["Phone nr is invalid"]
end
it 'should require country code when bic' do
@contact.ident_type = 'bic'
@contact.valid?
@contact.errors[:ident_country_code].should == ['is missing']
end
it 'should require country code when priv' do
@contact.ident_type = 'priv'
@contact.valid?
@contact.errors[:ident_country_code].should == ['is missing']
end
it 'should validate correct country code' do
@contact.ident_type = 'bic'
@contact.ident_country_code = 'EE'
@contact.valid?
@contact.errors[:ident_country_code].should == []
end
it 'should require valid country code' do
@contact.ident_type = 'bic'
@contact.ident_country_code = 'INVALID'
@contact.valid?
@contact.errors[:ident_country_code].should == ['is not following ISO_3166-1 alpha 2 format']
end
it 'should convert to alpha2 country code' do
@contact.ident_type = 'bic'
@contact.ident_country_code = 'ee'
@contact.valid?
@contact.ident_country_code.should == 'EE'
end
it 'should not have any versions' do
@contact.versions.should == []
end
@ -87,18 +123,12 @@ describe Contact do
@contact.relations_with_domain?.should == false
end
# it 'ico should be valid' do
# @contact.ident_type = 'ico'
# @contact.ident = '1234'
# @contact.errors.full_messages.should match_array([])
# end
# it 'ident should return false' do
# puts @contact.ident_type
# @contact.ident = '123abc'
# @contact.valid?
# @contact.errors.full_messages.should_not == []
# end
it 'bic should be valid' do
@contact.ident_type = 'bic'
@contact.ident = '1234'
@contact.valid?
@contact.errors.full_messages.should match_array([])
end
context 'as birthday' do
before :all do
@ -177,16 +207,6 @@ describe Contact do
@contact.auth_info.should == 'qwe321'
end
end
context 'with creator' do
it 'should return username of creator' do
# @contact.creator_str.should == 'gitlab'
end
it 'should return username of updater' do
# @contact.updator.should == 'gitlab'
end
end
end
end
end