Address depricated, new contact requires, domain_contacts refactor

This commit is contained in:
Priit Tark 2015-03-31 15:15:19 +03:00
parent 0e252b0b6b
commit 5fd73b037a
38 changed files with 402 additions and 501 deletions

View file

@ -3,7 +3,6 @@ require 'rails_helper'
describe 'EPP Contact', epp: true do
before :all do
create_settings
create_disclosure_settings
@registrar1 = Fabricate(:registrar1)
@registrar2 = Fabricate(:registrar2)
@epp_xml = EppXml::Contact.new(cl_trid: 'ABC-12345')
@ -38,6 +37,7 @@ describe 'EPP Contact', epp: true do
addr: {
street: { value: '123 Example' },
city: { value: 'Tallinn' },
pc: { value: '123456' },
cc: { value: 'EE' }
}
},
@ -52,15 +52,19 @@ describe 'EPP Contact', epp: true do
response = epp_plain_request(@epp_xml.create, :xml)
response[:results][0][:msg].should ==
'Required parameter missing: create > create > postalInfo > name [name]'
response[:results][1][:msg].should ==
response[:results][1][:msg].should ==
'Required parameter missing: create > create > postalInfo > addr > street [street]'
response[:results][2][:msg].should ==
'Required parameter missing: create > create > postalInfo > addr > city [city]'
response[:results][2][:msg].should ==
response[:results][3][:msg].should ==
'Required parameter missing: create > create > postalInfo > addr > pc [pc]'
response[:results][4][:msg].should ==
'Required parameter missing: create > create > postalInfo > addr > cc [cc]'
response[:results][3][:msg].should ==
response[:results][5][:msg].should ==
'Required parameter missing: create > create > voice [voice]'
response[:results][4][:msg].should ==
response[:results][6][:msg].should ==
'Required parameter missing: create > create > email [email]'
response[:results][5][:msg].should ==
response[:results][7][:msg].should ==
'Required parameter missing: extension > extdata > ident [ident]'
response[:results][0][:result_code].should == '2003'
@ -69,8 +73,10 @@ describe 'EPP Contact', epp: true do
response[:results][3][:result_code].should == '2003'
response[:results][4][:result_code].should == '2003'
response[:results][5][:result_code].should == '2003'
response[:results][6][:result_code].should == '2003'
response[:results][7][:result_code].should == '2003'
response[:results].count.should == 6
response[:results].count.should == 8
end
it 'successfully creates a contact' do
@ -84,7 +90,7 @@ describe 'EPP Contact', epp: true do
@contact.registrar.should == @registrar1
@registrar1.api_users.should include(@contact.creator)
@contact.ident.should == '37605030299'
@contact.address.street.should == '123 Example'
@contact.street.should == '123 Example'
@contact.legal_documents.count.should == 1
log = ApiLog::EppLog.last
@ -397,7 +403,7 @@ describe 'EPP Contact', epp: true do
it 'fails if contact has associated domain' do
@domain = Fabricate(:domain, registrar: @registrar1, owner_contact: @contact)
@domain.owner_contact.address.present?.should == true
@domain.owner_contact.present?.should == true
response = delete_request
response[:msg].should == 'Object association prohibits operation [domains]'
@ -480,8 +486,7 @@ describe 'EPP Contact', epp: true do
it 'return info about contact' do
@registrar1_contact = Fabricate(
:contact, code: 'info-4444', registrar: @registrar1,
name: 'Johnny Awesome', address: Fabricate(:address))
:contact, code: 'info-4444', registrar: @registrar1, name: 'Johnny Awesome')
response = info_request({ id: { value: @registrar1_contact.code } })
response[:msg].should == 'Command completed successfully'
@ -492,9 +497,8 @@ describe 'EPP Contact', epp: true do
end
it 'should return ident in extension' do
@registrar1_contact = Fabricate(
:contact, code: 'info-ident', registrar: @registrar1,
name: 'Johnny Awesome', address: Fabricate(:address))
@registrar1_contact = Fabricate(:contact, code: 'info-ident',
registrar: @registrar1, name: 'Johnny Awesome')
response = info_request({ id: { value: @registrar1_contact.code } })
response[:msg].should == 'Command completed successfully'

View file

@ -30,12 +30,12 @@ describe 'EPP Domain', epp: true do
]
}), :xml)
response[:results][0][:result_code].should == '2303'
response[:results][0][:msg].should == 'Contact was not found'
response[:results][0][:result_code].should == '2303'
response[:results][0][:value].should == 'sh1111'
response[:results][1][:result_code].should == '2303'
response[:results][1][:msg].should == 'Contact was not found'
response[:results][1][:result_code].should == '2303'
response[:results][1][:value].should == 'sh2222'
response[:clTRID].should == 'ABC-12345'
@ -95,8 +95,8 @@ describe 'EPP Domain', epp: true do
response[:clTRID].should == 'ABC-12345'
d.registrar.name.should == 'registrar1'
d.tech_contacts.count.should == 2
d.admin_contacts.count.should == 1
d.tech_contacts.count.should == 3
d.admin_contacts.count.should == 2
d.nameservers.count.should == 2
d.auth_info.should_not be_empty
@ -674,7 +674,7 @@ describe 'EPP Domain', epp: true do
})
response = epp_plain_request(xml, :xml)
response[:msg].should == 'Admin contacts count must be between 1-10 [admin_contacts]'
response[:msg].should == 'Admin contacts count must be between 1-10 [admin_domain_contacts]'
response[:result_code].should == '2004'
response[:clTRID].should == 'ABC-12345'
@ -1355,6 +1355,7 @@ describe 'EPP Domain', epp: true do
]
}), :xml)
response[:results][0][:msg].should == 'Command completed successfully'
response[:results][0][:result_code].should == '1000'
d = Domain.last
@ -1525,7 +1526,10 @@ describe 'EPP Domain', epp: true do
]
})
epp_plain_request(xml, :xml)
response = epp_plain_request(xml, :xml)
response[:results][0][:msg].should == 'Command completed successfully'
response[:results][0][:result_code].should == '1000'
d = Domain.last
d.dnskeys.count.should == 2
@ -1555,7 +1559,9 @@ describe 'EPP Domain', epp: true do
]
})
epp_plain_request(xml, :xml)
response = epp_plain_request(xml, :xml)
response[:results][0][:msg].should == 'Command completed successfully'
response[:results][0][:result_code].should == '1000'
d.dnskeys.count.should == 1
@ -1872,6 +1878,7 @@ describe 'EPP Domain', epp: true do
]
}), :xml)
response[:msg].should == 'Command completed successfully'
response[:result_code].should == '1000'
Domain.find_by(name: domain.name).should == nil

View file

@ -0,0 +1,6 @@
Fabricator(:admin_domain_contact) do
contact { Fabricate(:contact) }
after_build do |x|
x.contact_code_cache = x.contact.code
end
end

View file

@ -1,8 +0,0 @@
Fabricator(:contact_disclosure) do
email true
phone true
fax true
address true
name true
org_name true
end

View file

@ -1,15 +1,17 @@
Fabricator(:contact) do
registrar { Fabricate(:registrar) }
code { sequence(:code) { |i| "sh#{Faker::Number.number(8)}#{i}" } }
auth_info 'password'
name { sequence(:name) { |i| "#{Faker::Name.name}#{i}" } }
phone '+372.12345678'
email Faker::Internet.email
street 'Short street 11'
city 'Tallinn'
zip '11111'
country_code 'EE'
ident '37605030299'
ident_type 'priv'
ident_country_code 'EE'
address
registrar { Fabricate(:registrar) }
disclosure { Fabricate(:contact_disclosure) }
# rubocop: disable Style/SymbolProc
after_validation { |c| c.disable_generate_auth_info! }
# rubocop: enamble Style/SymbolProc

View file

@ -5,7 +5,7 @@ Fabricator(:domain) do
period_unit 'y'
owner_contact(fabricator: :contact)
nameservers(count: 3)
domain_contacts(count: 1) { Fabricate(:domain_contact, contact_type: 'admin') }
admin_domain_contacts(count: 1) { Fabricate(:admin_domain_contact) }
registrar
auth_info '98oiewslkfkd'
end

View file

@ -0,0 +1,6 @@
Fabricator(:tech_domain_contact) do
contact { Fabricate(:contact) }
after_build do |x|
x.contact_code_cache = x.contact.code
end
end

View file

@ -2,12 +2,9 @@ require 'rails_helper'
describe Contact do
before :all do
create_disclosure_settings
@api_user = Fabricate(:api_user)
end
it { should have_one(:address) }
context 'about class' do
it 'should have versioning enabled?' do
Contact.paper_trail_enabled_for_model?.should == true
@ -32,9 +29,12 @@ describe Contact do
"Email Required parameter missing - email",
"Email Email is invalid",
"Ident Required parameter missing - ident",
"Address is missing",
"Registrar is missing",
"Ident type is missing"
"Ident type is missing",
"City is missing",
"Country code is missing",
"Street is missing",
"Zip is missing"
])
end
@ -101,7 +101,7 @@ describe Contact do
context 'with valid attributes' do
before :all do
@contact = Fabricate(:contact, disclosure: nil)
@contact = Fabricate(:contact)
end
it 'should be valid' do
@ -169,11 +169,20 @@ describe Contact do
contact.statuses.map(&:value).should == %w(ok linked)
contact.domains.destroy_all
contact.save
contact.domains.first.destroy
contact.reload
contact.statuses.map(&:value).should == %w(ok)
end
it 'should have linked status when domain is created' do
# @admin_domain_contact = Fabricate(:admin_domain_contact)
# @domain = Fabricate(:domain, admin_domain_contacts: [@admin_domain_contact])
# puts @domain.contacts.size
# contact = @domain.contacts.first
# contact.statuses.map(&:value).should == %w(ok linked)
end
context 'as birthday' do
before :all do
@contact.ident_type = 'birthday'
@ -199,25 +208,6 @@ describe Contact do
end
end
it 'should have empty disclosure' do
@contact.disclosure.name.should == nil
@contact.disclosure.org_name.should == nil
@contact.disclosure.email.should == nil
@contact.disclosure.phone.should == nil
@contact.disclosure.fax.should == nil
@contact.disclosure.address.should == nil
end
it 'should have custom disclosure' do
@contact = Fabricate(:contact, disclosure: Fabricate(:contact_disclosure))
@contact.disclosure.name.should == true
@contact.disclosure.org_name.should == true
@contact.disclosure.email.should == true
@contact.disclosure.phone.should == true
@contact.disclosure.fax.should == true
@contact.disclosure.address.should == true
end
context 'with callbacks' do
before :all do
# Ensure callbacks are not taken out from other specs

View file

@ -22,7 +22,7 @@ describe Domain do
it 'should not be valid' do
@domain.valid?
@domain.errors.full_messages.should match_array([
"Admin contacts Admin contacts count must be between 1-10",
"Admin domain contacts Admin contacts count must be between 1-10",
"Nameservers Nameservers count must be between 2-11",
"Period Period is not a number",
"Registrant Registrant is missing",
@ -56,6 +56,24 @@ describe Domain do
@domain.errors.full_messages.should match_array([])
end
it 'should validate uniqueness of tech contacts' do
same_contact = Fabricate(:contact, code: 'same_contact')
domain = Fabricate(:domain)
domain.tech_contacts << same_contact
domain.tech_contacts << same_contact
domain.valid?
domain.errors.full_messages.should match_array(["Tech domain contacts is invalid"])
end
it 'should validate uniqueness of tech contacts' do
same_contact = Fabricate(:contact, code: 'same_contact')
domain = Fabricate(:domain)
domain.admin_contacts << same_contact
domain.admin_contacts << same_contact
domain.valid?
domain.errors.full_messages.should match_array(["Admin domain contacts is invalid"])
end
it 'should have whois_body' do
@domain.whois_body.present?.should == true
end
@ -102,20 +120,6 @@ describe Domain do
@domain.creator.should_not == @api_user
end
end
it 'should not find api creator when created by user' do
with_versioning do
# @api_user = Fabricate(:api_user)
# @api_user.id.should == 1
# ::PaperTrail.whodunnit = '1-testuser'
# @domain = Fabricate(:domain)
# @domain.creator_str.should == '1-testuser'
# @domain.api_creator.should == nil
end
end
end
end

View file

@ -19,15 +19,6 @@ module General
Setting.client_side_status_editing_enabled = true
end
def create_disclosure_settings
Setting.disclosure_name = true
Setting.disclosure_org_name = true
Setting.disclosure_email = true
Setting.disclosure_phone = false
Setting.disclosure_fax = false
Setting.disclosure_address = false
end
end
RSpec.configure do |c|