diff --git a/app/helpers/epp/contacts_helper.rb b/app/helpers/epp/contacts_helper.rb index 7a215f341..8d9a1d330 100644 --- a/app/helpers/epp/contacts_helper.rb +++ b/app/helpers/epp/contacts_helper.rb @@ -9,7 +9,7 @@ module Epp::ContactsHelper @contact.assign_attributes(name: ph[:postalInfo][:name]) - @contact.addresses << new_address + @contact.address = new_address stamp @contact @contact.save diff --git a/app/models/contact.rb b/app/models/contact.rb index 6f448eb02..3b23fbd8d 100644 --- a/app/models/contact.rb +++ b/app/models/contact.rb @@ -2,7 +2,7 @@ class Contact < ActiveRecord::Base #TODO Foreign contact will get email with activation link/username/temp password #TODO Phone number validation, in first phase very minimam in order to support current registries - has_many :addresses + has_one :address has_many :domain_contacts has_many :domains, through: :domain_contacts diff --git a/app/views/epp/contacts/info.xml.builder b/app/views/epp/contacts/info.xml.builder index b82736153..244690447 100644 --- a/app/views/epp/contacts/info.xml.builder +++ b/app/views/epp/contacts/info.xml.builder @@ -10,8 +10,8 @@ xml.epp_head do xml.tag!('contact:name', @contact.name) xml.tag!('contact:org', @contact.org_name) xml.tag!('contact:addr') do - xml.tag!('contact:street', @contact.addresses.first.street) - xml.tag!('contact:street', @contact.addresses.first.city) + xml.tag!('contact:street', @contact.address.street) + xml.tag!('contact:street', @contact.address.city) end xml.tag!('contact:voice', @contact.phone) xml.tag!('contact:fax', @contact.fax) diff --git a/spec/fabricators/contact_fabricator.rb b/spec/fabricators/contact_fabricator.rb index 4510a3632..7229760a9 100644 --- a/spec/fabricators/contact_fabricator.rb +++ b/spec/fabricators/contact_fabricator.rb @@ -5,5 +5,5 @@ Fabricator(:contact) do ident '37605030299' code 'sh8913' ident_type 'op' - addresses(count: 2) + address end diff --git a/spec/models/contact_spec.rb b/spec/models/contact_spec.rb index 1c0c0bc68..bce1b2ccb 100644 --- a/spec/models/contact_spec.rb +++ b/spec/models/contact_spec.rb @@ -1,7 +1,7 @@ require "rails_helper" describe Contact do - it { should have_many(:addresses) } + it { should have_one(:address) } context 'with invalid attribute' do before(:each) { @contact = Fabricate(:contact) }