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

@ -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