Improve ContactMailer

- Add detailed registrar info
- Refactor contact domain list
- Fix english translation

#480
This commit is contained in:
Artur Beljajev 2017-06-08 02:06:00 +03:00
parent 37004c24ba
commit 49552fc67e
11 changed files with 220 additions and 37 deletions

View file

@ -541,4 +541,58 @@ RSpec.describe Contact do
expect(contact.ident_country).to eq(Country.new('US'))
end
end
describe '#used?' do
context 'when used as registrant' do
let(:registrant) { create(:registrant) }
before :example do
create(:domain, registrant: registrant)
registrant.reload
end
specify { expect(registrant).to be_used }
end
context 'when used as contact' do
let(:contact) { create(:contact) }
before :example do
domain = create(:domain)
domain.admin_domain_contacts << create(:admin_domain_contact, contact: contact)
contact.reload
end
specify { expect(contact).to be_used }
end
context 'when not used' do
let(:contact) { create(:contact) }
specify { expect(contact).to_not be_used }
end
end
describe '#domain_names_with_roles' do
let(:contact) { create(:registrant) }
subject(:domain_names) { contact.domain_names_with_roles }
it 'returns associated domains with roles' do
domain = create(:domain, registrant: contact, name: 'test.com')
domain.admin_domain_contacts << create(:admin_domain_contact, contact: contact)
domain.tech_domain_contacts << create(:tech_domain_contact, contact: contact)
contact.reload
expect(domain_names).to eq({ 'test.com' => %i[registrant admin_domain_contact tech_domain_contact].to_set })
end
it 'returns unique roles' do
domain = create(:domain, name: 'test.com')
2.times { domain.admin_domain_contacts << create(:admin_domain_contact, contact: contact) }
contact.reload
expect(domain_names).to eq({ 'test.com' => %i[admin_domain_contact].to_set })
end
end
end