From 8cd3dcf5514a945345d01e41e6e224b24a952754 Mon Sep 17 00:00:00 2001 From: Priit Tark Date: Thu, 16 Apr 2015 12:23:06 +0300 Subject: [PATCH] Renamed owner_contact to registrant --- app/controllers/admin/domains_controller.rb | 2 +- app/controllers/epp/domains_controller.rb | 2 +- app/controllers/epp/keyrelays_controller.rb | 2 +- app/models/contact.rb | 4 +- app/models/domain.rb | 22 +- app/models/epp/domain.rb | 34 +- app/views/admin/domain_versions/_version.haml | 16 +- app/views/admin/domains/index.haml | 10 +- app/views/admin/domains/partials/_owner.haml | 22 +- app/views/epp/domains/info.xml.builder | 2 +- config/locales/en.yml | 4 +- ...91357_rename_domain_owner_to_registrant.rb | 5 + db/schema.rb | 2 +- doc/models_complete.svg | 691 ------------------ doc/repp/v1/domain.md | 2 +- lib/tasks/import.rake | 4 +- spec/epp/contact_spec.rb | 8 +- spec/epp/domain_spec.rb | 96 +-- spec/fabricators/domain_fabricator.rb | 2 +- spec/models/contact_spec.rb | 4 +- spec/models/domain_spec.rb | 4 +- 21 files changed, 126 insertions(+), 812 deletions(-) create mode 100644 db/migrate/20150416091357_rename_domain_owner_to_registrant.rb diff --git a/app/controllers/admin/domains_controller.rb b/app/controllers/admin/domains_controller.rb index 9bd1b86ac..8c9e114b9 100644 --- a/app/controllers/admin/domains_controller.rb +++ b/app/controllers/admin/domains_controller.rb @@ -3,7 +3,7 @@ class Admin::DomainsController < AdminController before_action :set_domain, only: [:show, :edit, :update, :zonefile] def index - @q = Domain.includes(:registrar, :owner_contact).search(params[:q]) + @q = Domain.includes(:registrar, :registrant).search(params[:q]) @domains = @q.result.page(params[:page]) end diff --git a/app/controllers/epp/domains_controller.rb b/app/controllers/epp/domains_controller.rb index 66fff5211..0b75f92e4 100644 --- a/app/controllers/epp/domains_controller.rb +++ b/app/controllers/epp/domains_controller.rb @@ -156,7 +156,7 @@ class Epp::DomainsController < EppController def find_domain domain_name = params[:parsed_frame].css('name').text.strip.downcase - @domain = Epp::Domain.where(name: domain_name).includes(owner_contact: :registrar).first + @domain = Epp::Domain.where(name: domain_name).includes(registrant: :registrar).first unless @domain epp_errors << { diff --git a/app/controllers/epp/keyrelays_controller.rb b/app/controllers/epp/keyrelays_controller.rb index 9384818ca..a2191c83d 100644 --- a/app/controllers/epp/keyrelays_controller.rb +++ b/app/controllers/epp/keyrelays_controller.rb @@ -34,7 +34,7 @@ class Epp::KeyrelaysController < EppController def find_domain domain_name = params[:parsed_frame].css('name').text.strip.downcase - domain = Epp::Domain.includes(:owner_contact).find_by(name: domain_name) + domain = Epp::Domain.includes(:registrant).find_by(name: domain_name) unless domain epp_errors << { diff --git a/app/models/contact.rb b/app/models/contact.rb index 5d0ba74b7..91e047b98 100644 --- a/app/models/contact.rb +++ b/app/models/contact.rb @@ -74,7 +74,7 @@ class Contact < ActiveRecord::Base def find_orphans Contact.where(' NOT EXISTS( - select 1 from domains d where d.owner_contact_id = contacts.id + select 1 from domains d where d.registrant_id = contacts.id ) AND NOT EXISTS( select 1 from domain_contacts dc where dc.contact_id = contacts.id ) @@ -138,7 +138,7 @@ class Contact < ActiveRecord::Base # Find a way to use self.domains with contact def domains_owned - Domain.where(owner_contact_id: id) + Domain.where(registrant_id: id) end def relations_with_domain? diff --git a/app/models/domain.rb b/app/models/domain.rb index 37e74e7f6..3b71185eb 100644 --- a/app/models/domain.rb +++ b/app/models/domain.rb @@ -7,7 +7,7 @@ class Domain < ActiveRecord::Base paginates_per 10 # just for showoff belongs_to :registrar - belongs_to :owner_contact, class_name: 'Contact' + belongs_to :registrant, class_name: 'Contact' has_many :domain_contacts, dependent: :destroy has_many :admin_domain_contacts @@ -39,10 +39,10 @@ class Domain < ActiveRecord::Base has_many :legal_documents, as: :documentable accepts_nested_attributes_for :legal_documents, reject_if: proc { |attrs| attrs[:body].blank? } - delegate :code, to: :owner_contact, prefix: true - delegate :email, to: :owner_contact, prefix: true - delegate :ident, to: :owner_contact, prefix: true - delegate :phone, to: :owner_contact, prefix: true + delegate :code, to: :registrant, prefix: true + delegate :email, to: :registrant, prefix: true + delegate :ident, to: :registrant, prefix: true + delegate :phone, to: :registrant, prefix: true delegate :name, to: :registrar, prefix: true before_create :generate_auth_info @@ -57,7 +57,7 @@ class Domain < ActiveRecord::Base validates :name_dirty, domain_name: true, uniqueness: true validates :period, numericality: { only_integer: true } - validates :owner_contact, :registrar, presence: true + validates :registrant, :registrar, presence: true validate :validate_period @@ -103,7 +103,7 @@ class Domain < ActiveRecord::Base validate :validate_nameserver_ips - attr_accessor :owner_contact_typeahead, :update_me + attr_accessor :registrant_typeahead, :update_me def subordinate_nameservers nameservers.select { |x| x.hostname.end_with?(name) } @@ -138,8 +138,8 @@ class Domain < ActiveRecord::Base self[:name_dirty] = value end - def owner_contact_typeahead - @owner_contact_typeahead || owner_contact.try(:name) || nil + def registrant_typeahead + @registrant_typeahead || registrant.try(:name) || nil end def pending_transfer @@ -234,7 +234,7 @@ class Domain < ActiveRecord::Base log[:admin_contacts] = admin_contacts.map(&:attributes) log[:tech_contacts] = tech_contacts.map(&:attributes) log[:nameservers] = nameservers.map(&:attributes) - log[:owner_contact] = [owner_contact.try(:attributes)] + log[:registrant] = [registrant.try(:attributes)] log end @@ -244,7 +244,7 @@ class Domain < ActiveRecord::Base Estonia .ee Top Level Domain WHOIS server domain: #{name} - registrant: #{owner_contact.name} + registrant: #{registrant.name} status: #{domain_statuses.map(&:value).join(', ')} registered: #{registered_at and registered_at.to_s(:db)} changed: #{updated_at and updated_at.to_s(:db)} diff --git a/app/models/epp/domain.rb b/app/models/epp/domain.rb index 359495ed6..2a29aab32 100644 --- a/app/models/epp/domain.rb +++ b/app/models/epp/domain.rb @@ -24,7 +24,7 @@ class Epp::Domain < Domain [:base, :domain_status_prohibits_operation] ], '2306' => [ # Parameter policy error - [:owner_contact, :blank], + [:registrant, :blank], [:base, :ds_data_with_key_not_allowed], [:base, :ds_data_not_allowed], [:base, :key_data_not_allowed], @@ -68,9 +68,9 @@ class Epp::Domain < Domain end def attach_default_contacts - return if owner_contact.blank? - tech_contacts << owner_contact if tech_contacts.blank? - admin_contacts << owner_contact if admin_contacts.blank? && owner_contact.priv? + return if registrant.blank? + tech_contacts << registrant if tech_contacts.blank? + admin_contacts << registrant if admin_contacts.blank? && registrant.priv? end # rubocop: disable Metrics/PerceivedComplexity @@ -84,9 +84,9 @@ class Epp::Domain < Domain oc = Contact.find_by(code: code).try(:id) if oc - at[:owner_contact_id] = oc + at[:registrant_id] = oc else - add_epp_error('2303', 'registrant', code, [:owner_contact, :not_found]) + add_epp_error('2303', 'registrant', code, [:registrant, :not_found]) end end @@ -430,7 +430,7 @@ class Epp::Domain < Domain # TODO: Eager load problems here. Investigate how it's possible not to query contact again # Check if versioning works with update_column def transfer_contacts(registrar_id) - transfer_owner_contact(registrar_id) + transfer_registrant(registrar_id) transfer_domain_contacts(registrar_id) end @@ -452,15 +452,15 @@ class Epp::Domain < Domain oc end - def transfer_owner_contact(registrar_id) - return if owner_contact.registrar_id == registrar_id + def transfer_registrant(registrar_id) + return if registrant.registrar_id == registrar_id - is_other_domains_contact = DomainContact.where('contact_id = ? AND domain_id != ?', owner_contact_id, id).count > 0 - if owner_contact.domains_owned.count > 1 || is_other_domains_contact - oc = copy_and_transfer_contact(owner_contact_id, registrar_id) - self.owner_contact_id = oc.id + is_other_domains_contact = DomainContact.where('contact_id = ? AND domain_id != ?', registrant_id, id).count > 0 + if registrant.domains_owned.count > 1 || is_other_domains_contact + oc = copy_and_transfer_contact(registrant_id, registrar_id) + self.registrant_id = oc.id else - transfer_contact(owner_contact_id, registrar_id) + transfer_contact(registrant_id, registrar_id) end end @@ -471,11 +471,11 @@ class Epp::Domain < Domain is_other_domains_contact = DomainContact.where('contact_id = ? AND domain_id != ?', c.id, id).count > 0 # if contact used to be owner contact but was copied, then contact must be transferred - # (owner_contact_id_was != c.id) + # (registrant_id_was != c.id) if c.domains.count > 1 || is_other_domains_contact # copy contact - if owner_contact_id_was == c.id # owner contact was copied previously, do not copy it again - oc = OpenStruct.new(id: owner_contact_id) + if registrant_id_was == c.id # owner contact was copied previously, do not copy it again + oc = OpenStruct.new(id: registrant_id) else oc = copy_and_transfer_contact(c.id, registrar_id) end diff --git a/app/views/admin/domain_versions/_version.haml b/app/views/admin/domain_versions/_version.haml index 8cbee678f..9d273892e 100644 --- a/app/views/admin/domain_versions/_version.haml +++ b/app/views/admin/domain_versions/_version.haml @@ -2,7 +2,7 @@ - nameservers = children[:nameservers] || [] - tech_contacts = children[:tech_contacts] || [] - admin_contacts = children[:admin_contacts] || [] -- owner_contact = children[:owner_contact] || [] +- registrant = children[:registrant] || [] %td %p.nowrap @@ -19,7 +19,7 @@ = domain.status %td - - owner_contact.each do |oc| + - registrant.each do |oc| %p = oc[:name] = oc[:phone] @@ -75,16 +75,16 @@ -# = ',' + children[:domain][:status] --# %td{ class: changes.include?(:owner_contact) ? 'edit-highlight' : 'no-highlight' } - -# - if children[:owner_contact] +-# %td{ class: changes.include?(:registrant) ? 'edit-highlight' : 'no-highlight' } + -# - if children[:registrant] -# %p{:style => "font-size:x-small;"} - -# = children[:owner_contact][:name] + -# = children[:registrant][:name] -# = "," - -# = children[:owner_contact][:phone] + -# = children[:registrant][:phone] -# = "," - -# = children[:owner_contact][:email] + -# = children[:registrant][:email] -# = "," - -# = children[:owner_contact][:code] + -# = children[:registrant][:code] -# %td{ class: changes.include?(:admin_contacts) ? 'edit-highlight' : 'no-highlight' } -# - if children[:admin_contacts] diff --git a/app/views/admin/domains/index.haml b/app/views/admin/domains/index.haml index 3fa754201..703cca921 100644 --- a/app/views/admin/domains/index.haml +++ b/app/views/admin/domains/index.haml @@ -1,6 +1,6 @@ .row .col-sm-12 - %h2.text-center-xs= t('domains') + %h2.text-center-xs= t(:domains) %hr .row .col-md-12 @@ -24,16 +24,16 @@ %th{class: 'col-xs-2'} = sort_link(@q, 'name') %th{class: 'col-xs-2'} - = sort_link(@q, 'owner_contact_name', t('owner')) + = sort_link(@q, 'registrant_name', t(:registrant)) %th{class: 'col-xs-2'} - = sort_link(@q, 'valid_to', t('valid_to')) + = sort_link(@q, 'valid_to', t(:valid_to)) %th{class: 'col-xs-2'} - = sort_link(@q, 'registrar_name', t('registrar')) + = sort_link(@q, 'registrar_name', t(:registrar)) %tbody - @domains.each do |x| %tr %td= link_to(x, admin_domain_path(x)) - %td= link_to(x.owner_contact, [:admin, x.owner_contact]) + %td= link_to(x.registrant, [:admin, x.registrant]) %td= l(x.valid_to, format: :short) %td= link_to(x.registrar, admin_registrar_path(x.registrar)) if x.registrar .row diff --git a/app/views/admin/domains/partials/_owner.haml b/app/views/admin/domains/partials/_owner.haml index 648f127de..e005183fb 100644 --- a/app/views/admin/domains/partials/_owner.haml +++ b/app/views/admin/domains/partials/_owner.haml @@ -1,19 +1,19 @@ .panel.panel-default .panel-heading - %h3.panel-title= t('owner') + %h3.panel-title= t(:registrant) .panel-body %dl.dl-horizontal - %dt= t('name') - %dd= link_to(@domain.owner_contact, [:admin, @domain.owner_contact]) + %dt= t(:name) + %dd= link_to(@domain.registrant, [:admin, @domain.registrant]) - %dt= t('code') - %dd= @domain.owner_contact_code + %dt= t(:code) + %dd= @domain.registrant_code - %dt= t('identity_code') - %dd= @domain.owner_contact_ident + %dt= t(:identity_code) + %dd= @domain.registrant_ident - %dt= t('email') - %dd= @domain.owner_contact_email + %dt= t(:email) + %dd= @domain.registrant_email - %dt= t('phone') - %dd= @domain.owner_contact_phone + %dt= t(:phone) + %dd= @domain.registrant_phone diff --git a/app/views/epp/domains/info.xml.builder b/app/views/epp/domains/info.xml.builder index 70d1e46ad..4590eafb4 100644 --- a/app/views/epp/domains/info.xml.builder +++ b/app/views/epp/domains/info.xml.builder @@ -12,7 +12,7 @@ xml.epp_head do xml.tag!('domain:status', 's' => ds.value) if ds.description.blank? end - xml.tag!('domain:registrant', @domain.owner_contact_code) + xml.tag!('domain:registrant', @domain.registrant_code) @domain.tech_contacts.each do |tc| xml.tag!('domain:contact', tc.code, 'type' => 'tech') diff --git a/config/locales/en.yml b/config/locales/en.yml index 46fb51be0..b18e32ec8 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -63,7 +63,7 @@ en: invalid: 'Domain name is invalid' reserved: 'Domain name is reserved or restricted' taken: 'Domain name already exists' - owner_contact: + registrant: blank: 'Registrant is missing' not_found: 'Registrant not found' domain_contacts: @@ -201,7 +201,7 @@ en: name: 'Domain name' name_dirty: 'Domain name' name_puny: 'Domain name' - owner_contact: 'Registrant' + registrant: 'Registrant' nameservers: 'Nameservers' domain: <<: *epp_domain_attributes diff --git a/db/migrate/20150416091357_rename_domain_owner_to_registrant.rb b/db/migrate/20150416091357_rename_domain_owner_to_registrant.rb new file mode 100644 index 000000000..389906b2c --- /dev/null +++ b/db/migrate/20150416091357_rename_domain_owner_to_registrant.rb @@ -0,0 +1,5 @@ +class RenameDomainOwnerToRegistrant < ActiveRecord::Migration + def change + rename_column :domains, :owner_contact_id, :registrant_id + end +end diff --git a/db/schema.rb b/db/schema.rb index 5b91817ed..796d36b41 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -249,7 +249,7 @@ ActiveRecord::Schema.define(version: 20150416080828) do t.string "status" t.datetime "valid_from" t.datetime "valid_to" - t.integer "owner_contact_id" + t.integer "registrant_id" t.string "auth_info" t.datetime "created_at" t.datetime "updated_at" diff --git a/doc/models_complete.svg b/doc/models_complete.svg index 3117c3bfa..e69de29bb 100644 --- a/doc/models_complete.svg +++ b/doc/models_complete.svg @@ -1,691 +0,0 @@ - - - - - - -models_diagram - - -_diagram_info -Models diagram -Date: Dec 15 2014 - 14:23 -Migration version: 20141202114457 -Generated by RailRoady 1.2.0 -http://railroady.prestonlee.com - - -Ability - -Ability - - - - -ContactDisclosure - -ContactDisclosure - -id :integer -contact_id :integer -phone :boolean -fax :boolean -email :boolean -created_at :datetime -updated_at :datetime -name :boolean -org_name :boolean -address :boolean - - -DomainStatusVersion - -DomainStatusVersion - -id :integer -item_type :string -item_id :integer -event :string -whodunnit :string -object :text -created_at :datetime - - -DomainContact - -DomainContact - -id :integer -contact_id :integer -domain_id :integer -contact_type :string -created_at :datetime -updated_at :datetime - - -Right - -Right - -id :integer -code :string -created_at :datetime -updated_at :datetime - - -Role - -Role - -id :integer -name :string -created_at :datetime -updated_at :datetime - - -Right->Role - - - - - -Contact - -Contact - -id :integer -code :string -type :string -reg_no :string -phone :string -email :string -fax :string -created_at :datetime -updated_at :datetime -ident :string -ident_type :string -created_by_id :integer -updated_by_id :integer -auth_info :string -name :string -org_name :string -registrar_id :integer - - -Contact->ContactDisclosure - - - -disclosure - - -Contact->DomainContact - - - - - -ContactVersion - -ContactVersion - -id :integer -item_type :string -item_id :integer -event :string -whodunnit :string -object :text -created_at :datetime - - -Contact->ContactVersion - - - -versions - - -Address - -Address - -id :integer -contact_id :integer -country_id :integer -city :string -street :string -zip :string -created_at :datetime -updated_at :datetime -street2 :string -street3 :string - - -Contact->Address - - - - - -Domain - -Domain - -id :integer -name :string -registrar_id :integer -registered_at :datetime -status :string -valid_from :datetime -valid_to :datetime -owner_contact_id :integer -auth_info :string -created_at :datetime -updated_at :datetime -name_dirty :string -name_puny :string -period :integer -period_unit :string - - -Contact->Domain - - - - - -DomainVersion - -DomainVersion - -id :integer -item_type :string -item_id :integer -event :string -whodunnit :string -object :text -created_at :datetime -snapshot :text - - -Setting - -Setting - -id :integer -var :string -value :text -thing_id :integer -thing_type :string -created_at :datetime -updated_at :datetime - - -Nameserver - -Nameserver - -id :integer -hostname :string -ipv4 :string -created_at :datetime -updated_at :datetime -ipv6 :string -domain_id :integer - - -NameserverVersion - -NameserverVersion - -id :integer -item_type :string -item_id :integer -event :string -whodunnit :string -object :text -created_at :datetime - - -Nameserver->NameserverVersion - - - -versions - - -EppUser - -EppUser - -id :integer -registrar_id :integer -username :string -password :string -active :boolean -csr :text -crt :text -created_at :datetime -updated_at :datetime - - -EppUser->Contact - - - - - -Country - -Country - -id :integer -iso :string -name :string -created_at :datetime -updated_at :datetime - - -ZonefileSetting - -ZonefileSetting - -id :integer -origin :string -ttl :integer -refresh :integer -retry :integer -expire :integer -minimum_ttl :integer -email :string -master_nameserver :string -created_at :datetime -updated_at :datetime - - -CachedNameserver - -CachedNameserver - -hostname :string -ipv4 :string -ipv6 :string - - -Epp::EppDomain - -Epp::EppDomain - -id :integer -name :string -registrar_id :integer -registered_at :datetime -status :string -valid_from :datetime -valid_to :datetime -owner_contact_id :integer -auth_info :string -created_at :datetime -updated_at :datetime -name_dirty :string -name_puny :string -period :integer -period_unit :string - - -Epp::DomainContact - -Epp::DomainContact - - -Epp::EppDomain->Epp::DomainContact - - - - - -Epp::Contact - -Epp::Contact - - -Epp::EppDomain->Epp::Contact - - - -tech_contacts - - -Epp::EppDomain->Epp::Contact - - - -admin_contacts - - -Epp::Nameserver - -Epp::Nameserver - - -Epp::EppDomain->Epp::Nameserver - - - - - -Epp::DomainStatus - -Epp::DomainStatus - - -Epp::EppDomain->Epp::DomainStatus - - - - - -Epp::DomainTransfer - -Epp::DomainTransfer - - -Epp::EppDomain->Epp::DomainTransfer - - - - - -Epp::Dnskey - -Epp::Dnskey - - -Epp::EppDomain->Epp::Dnskey - - - - - -Epp::Keyrelay - -Epp::Keyrelay - - -Epp::EppDomain->Epp::Keyrelay - - - - - -Epp::DomainVersion - -Epp::DomainVersion - - -Epp::EppDomain->Epp::DomainVersion - - - -versions - - -Message - -Message - -id :integer -registrar_id :integer -body :string -attached_obj_type :string -attached_obj_id :string -queued :boolean -created_at :datetime -updated_at :datetime - - -EppSession - -EppSession - -id :integer -session_id :string -data :text -created_at :datetime -updated_at :datetime - - -AddressVersion - -AddressVersion - -id :integer -item_type :string -item_id :integer -event :string -whodunnit :string -object :text -created_at :datetime - - -Keyrelay - -Keyrelay - -id :integer -domain_id :integer -pa_date :datetime -key_data_flags :string -key_data_protocol :string -key_data_alg :string -key_data_public_key :text -auth_info_pw :string -expiry_relative :string -expiry_absolute :datetime -requester_id :integer -accepter_id :integer -created_at :datetime -updated_at :datetime - - -ReservedDomain - -ReservedDomain - -id :integer -name :string -created_at :datetime -updated_at :datetime - - -Registrar - -Registrar - -id :integer -name :string -reg_no :string -vat_no :string -address :string -country_id :integer -billing_address :string -created_at :datetime -updated_at :datetime - - -Registrar->Contact - - - - - -Registrar->EppUser - - - - - -Registrar->Message - - - - - -User - -User - -id :integer -username :string -password :string -role_id :integer -created_at :datetime -updated_at :datetime -email :string -sign_in_count :integer -current_sign_in_at :datetime -last_sign_in_at :datetime -current_sign_in_ip :inet -last_sign_in_ip :inet -admin :boolean -identity_code :string -registrar_id :integer -country_id :integer - - -Registrar->User - - - - - -Registrar->Domain - - - - - -Role->User - - - - - -Address->AddressVersion - - - -versions - - -Domain->DomainContact - - - - - -Domain->Contact - - - -tech_contacts - - -Domain->Contact - - - -admin_contacts - - -Domain->DomainVersion - - - -versions - - -Domain->Nameserver - - - - - -Domain->Keyrelay - - - - - -Dnskey - -Dnskey - -id :integer -domain_id :integer -flags :integer -protocol :integer -alg :integer -public_key :text -delegation_signer_id :integer -ds_key_tag :string -ds_alg :integer -ds_digest_type :integer -ds_digest :string - - -Domain->Dnskey - - - - - -DomainTransfer - -DomainTransfer - -id :integer -domain_id :integer -status :string -transfer_requested_at :datetime -transferred_at :datetime -transfer_from_id :integer -transfer_to_id :integer -created_at :datetime -updated_at :datetime -wait_until :datetime - - -Domain->DomainTransfer - - - - - -DomainStatus - -DomainStatus - -id :integer -domain_id :integer -description :string -value :string - - -Domain->DomainStatus - - - - - -DomainStatus->DomainStatusVersion - - - -versions - - - diff --git a/doc/repp/v1/domain.md b/doc/repp/v1/domain.md index 28ac7aa1d..e09f75ace 100644 --- a/doc/repp/v1/domain.md +++ b/doc/repp/v1/domain.md @@ -36,7 +36,7 @@ Content-Type: application/json "status": null, "valid_from": "2015-04-16T00:00:00.000Z", "valid_to": "2016-04-16T00:00:00.000Z", - "owner_contact_id": 1, + "registrant_id": 1, "auth_info": "3ec9a29d618023920b61758c339b638f", "created_at": "2015-04-16T08:48:39.992Z", "updated_at": "2015-04-16T08:48:39.991Z", diff --git a/lib/tasks/import.rake b/lib/tasks/import.rake index 9c33f1dff..a3784e5ae 100644 --- a/lib/tasks/import.rake +++ b/lib/tasks/import.rake @@ -402,11 +402,11 @@ namespace :import do # registrant ActiveRecord::Base.connection.execute( "UPDATE domains "\ - "SET owner_contact_id = contacts.id "\ + "SET registrant_id = contacts.id "\ "FROM contacts "\ "WHERE contacts.legacy_id = legacy_registrant_id "\ "AND legacy_registrant_id IS NOT NULL "\ - "AND owner_contact_id IS NULL" + "AND registrant_id IS NULL" ) # registrar diff --git a/spec/epp/contact_spec.rb b/spec/epp/contact_spec.rb index 45a00120b..2de7040ef 100644 --- a/spec/epp/contact_spec.rb +++ b/spec/epp/contact_spec.rb @@ -402,15 +402,15 @@ describe 'EPP Contact', epp: true do end it 'fails if contact has associated domain' do - @domain = Fabricate(:domain, registrar: @registrar1, owner_contact: @contact) - @domain.owner_contact.present?.should == true + @domain = Fabricate(:domain, registrar: @registrar1, registrant: @contact) + @domain.registrant.present?.should == true response = delete_request response[:msg].should == 'Object association prohibits operation [domains]' response[:result_code].should == '2305' response[:results].count.should == 1 - @domain.owner_contact.present?.should == true + @domain.registrant.present?.should == true end it 'fails with wrong authentication info' do @@ -511,7 +511,7 @@ describe 'EPP Contact', epp: true do contact.css('ident').first.text.should == '37605030299' end - it 'returns no authorization error for wrong password when owner' do + it 'returns no authorization error for wrong password when registrant' do response = info_request({ authInfo: { pw: { value: 'wrong-pw' } } }) response[:msg].should == 'Command completed successfully' diff --git a/spec/epp/domain_spec.rb b/spec/epp/domain_spec.rb index 5063ee25b..efebf69ee 100644 --- a/spec/epp/domain_spec.rb +++ b/spec/epp/domain_spec.rb @@ -75,7 +75,7 @@ describe 'EPP Domain', epp: true do 'Required parameter missing: extension > extdata > legalDocument [legal_document]' end - context 'with citizen as an owner' do + context 'with citizen as a registrant' do it 'creates a domain' do dn = next_domain_name response = epp_plain_request(domain_create_xml({ @@ -642,7 +642,7 @@ describe 'EPP Domain', epp: true do end end - context 'with juridical persion as an owner' do + context 'with juridical persion as a registrant' do it 'creates a domain with contacts' do xml = domain_create_xml({ registrant: { value: 'juridical_1234' }, @@ -881,8 +881,8 @@ describe 'EPP Domain', epp: true do end it 'transfers domain with contacts' do - original_oc_id = domain.owner_contact.id - original_oc_code = domain.owner_contact.code + original_oc_id = domain.registrant.id + original_oc_code = domain.registrant.code original_contact_codes = domain.contacts.pluck(:code) @@ -899,12 +899,12 @@ describe 'EPP Domain', epp: true do end # all domain contacts should be under registrar2 now - domain.owner_contact.reload - domain.owner_contact.registrar_id.should == @registrar2.id - domain.owner_contact.id.should == original_oc_id + domain.registrant.reload + domain.registrant.registrar_id.should == @registrar2.id + domain.registrant.id.should == original_oc_id # must generate new code - domain.owner_contact.code.should_not == original_oc_code + domain.registrant.code.should_not == original_oc_code domain.contacts.each do |c| c.registrar_id.should == @registrar2.id @@ -913,9 +913,9 @@ describe 'EPP Domain', epp: true do end it 'transfers domain when registrant has more domains' do - Fabricate(:domain, owner_contact: domain.owner_contact) - original_oc_id = domain.owner_contact.id - original_oc_code = domain.owner_contact.code + Fabricate(:domain, registrant: domain.registrant) + original_oc_id = domain.registrant.id + original_oc_code = domain.registrant.code original_contact_codes = domain.contacts.pluck(:code) @@ -933,11 +933,11 @@ describe 'EPP Domain', epp: true do # all domain contacts should be under registrar2 now domain.reload - domain.owner_contact.registrar_id.should == @registrar2.id - # owner_contact should be a new record - domain.owner_contact.id.should_not == original_oc_id + domain.registrant.registrar_id.should == @registrar2.id + # registrant should be a new record + domain.registrant.id.should_not == original_oc_id # must generate new code - domain.owner_contact.code.should_not == original_oc_code + domain.registrant.code.should_not == original_oc_code domain.contacts.each do |c| c.registrar_id.should == @registrar2.id @@ -947,10 +947,10 @@ describe 'EPP Domain', epp: true do it 'transfers domain when registrant is admin or tech contact on some other domain' do d = Fabricate(:domain) - d.tech_contacts << domain.owner_contact + d.tech_contacts << domain.registrant - original_oc_id = domain.owner_contact.id - original_oc_code = domain.owner_contact.code + original_oc_id = domain.registrant.id + original_oc_code = domain.registrant.code original_contact_codes = domain.contacts.pluck(:code) @@ -968,11 +968,11 @@ describe 'EPP Domain', epp: true do # all domain contacts should be under registrar2 now domain.reload - domain.owner_contact.registrar_id.should == @registrar2.id - # owner_contact should be a new record - domain.owner_contact.id.should_not == original_oc_id + domain.registrant.registrar_id.should == @registrar2.id + # registrant should be a new record + domain.registrant.id.should_not == original_oc_id # must generate new code - domain.owner_contact.code.should_not == original_oc_code + domain.registrant.code.should_not == original_oc_code domain.contacts.each do |c| c.registrar_id.should == @registrar2.id @@ -988,7 +988,7 @@ describe 'EPP Domain', epp: true do d = Fabricate(:domain) d.tech_contacts << old_contact d.admin_contacts << old_contact - original_oc_id = domain.owner_contact.id + original_oc_id = domain.registrant.id original_contact_count = Contact.count original_domain_contact_count = DomainContact.count @@ -1006,9 +1006,9 @@ describe 'EPP Domain', epp: true do # all domain contacts should be under registrar2 now domain.reload - domain.owner_contact.registrar_id.should == @registrar2.id - # owner_contact should not be a new record - domain.owner_contact.id.should == original_oc_id + domain.registrant.registrar_id.should == @registrar2.id + # registrant should not be a new record + domain.registrant.id.should == original_oc_id # old contact must not change old_contact.registrar_id.should == @registrar1.id @@ -1042,7 +1042,7 @@ describe 'EPP Domain', epp: true do d.tech_contacts << old_contact d.admin_contacts << old_contact_2 - original_oc_id = domain.owner_contact.id + original_oc_id = domain.registrant.id original_contact_count = Contact.count original_domain_contact_count = DomainContact.count @@ -1060,9 +1060,9 @@ describe 'EPP Domain', epp: true do # all domain contacts should be under registrar2 now domain.reload - domain.owner_contact.registrar_id.should == @registrar2.id - # owner_contact should not be a new record - domain.owner_contact.id.should == original_oc_id + domain.registrant.registrar_id.should == @registrar2.id + # registrant should not be a new record + domain.registrant.id.should == original_oc_id # old contact must not change old_contact.registrar_id.should == @registrar1.id @@ -1088,12 +1088,12 @@ describe 'EPP Domain', epp: true do original_domain_contact_count.should == DomainContact.count end - it 'transfers domain and references exsisting owner contact to domain contacts' do + it 'transfers domain and references exsisting registrant to domain contacts' do d = Fabricate(:domain) - d.tech_contacts << domain.owner_contact + d.tech_contacts << domain.registrant - domain.tech_contacts << domain.owner_contact - original_owner_contact_id = domain.owner_contact_id + domain.tech_contacts << domain.registrant + original_registrant_id = domain.registrant_id pw = domain.auth_info xml = domain_transfer_xml({ @@ -1108,11 +1108,11 @@ describe 'EPP Domain', epp: true do end domain.reload - # owner contact must be an new record - domain.owner_contact_id.should_not == original_owner_contact_id + # registrant must be an new record + domain.registrant_id.should_not == original_registrant_id - # new owner contact must be a tech contact - domain.domain_contacts.where(contact_id: domain.owner_contact_id).count.should == 1 + # new registrant must be a tech contact + domain.domain_contacts.where(contact_id: domain.registrant_id).count.should == 1 end it 'does not transfer contacts if they are already under new registrar' do @@ -1121,11 +1121,11 @@ describe 'EPP Domain', epp: true do c.save end - domain.owner_contact.registrar_id = @registrar2.id - domain.owner_contact.save + domain.registrant.registrar_id = @registrar2.id + domain.registrant.save - original_oc_id = domain.owner_contact_id - original_oc_code = domain.owner_contact.code + original_oc_id = domain.registrant_id + original_oc_code = domain.registrant.code original_contacts_codes = domain.contacts.pluck(:code) pw = domain.auth_info @@ -1142,9 +1142,9 @@ describe 'EPP Domain', epp: true do domain.reload - domain.owner_contact.id.should == original_oc_id - domain.owner_contact.code.should == original_oc_code - domain.owner_contact.registrar_id.should == @registrar2.id + domain.registrant.id.should == original_oc_id + domain.registrant.code.should == original_oc_code + domain.registrant.registrar_id.should == @registrar2.id original_contacts_codes.should == domain.contacts.pluck(:code) @@ -1278,7 +1278,7 @@ describe 'EPP Domain', epp: true do response[:msg].should == 'Authorization error' end - it 'ignores transfer when owner registrar requests transfer' do + it 'ignores transfer wha registrant registrar requests transfer' do pw = domain.auth_info xml = domain_transfer_xml({ name: { value: domain.name }, @@ -1370,7 +1370,7 @@ describe 'EPP Domain', epp: true do d = Domain.last - d.owner_contact_code.should == 'citizen_1234' + d.registrant_code.should == 'citizen_1234' d.auth_info.should == existing_pw end @@ -1765,7 +1765,7 @@ describe 'EPP Domain', epp: true do inf_data.css('name').text.should == domain.name inf_data.css('status').text.should == 'Payment overdue.' inf_data.css('status').first[:s].should == 'clientHold' - inf_data.css('registrant').text.should == domain.owner_contact_code + inf_data.css('registrant').text.should == domain.registrant_code admin_contacts_from_request = inf_data.css('contact[type="admin"]').map(&:text) admin_contacts_existing = domain.admin_contacts.pluck(:code) diff --git a/spec/fabricators/domain_fabricator.rb b/spec/fabricators/domain_fabricator.rb index 85c78671c..7f8e897f6 100644 --- a/spec/fabricators/domain_fabricator.rb +++ b/spec/fabricators/domain_fabricator.rb @@ -3,7 +3,7 @@ Fabricator(:domain) do valid_to Date.new(2014, 8, 7) period 1 period_unit 'y' - owner_contact(fabricator: :contact) + registrant(fabricator: :contact) nameservers(count: 3) admin_domain_contacts(count: 1) { Fabricate(:admin_domain_contact) } tech_domain_contacts(count: 1) { Fabricate(:tech_domain_contact) } diff --git a/spec/models/contact_spec.rb b/spec/models/contact_spec.rb index a47d15200..2b2445080 100644 --- a/spec/models/contact_spec.rb +++ b/spec/models/contact_spec.rb @@ -326,13 +326,13 @@ describe Contact, '.destroy_orphans' do end it 'should find one orphan' do - Fabricate(:domain, owner_contact: @contact_1) + Fabricate(:domain, registrant: @contact_1) Contact.find_orphans.count.should == 1 Contact.find_orphans.last.should == @contact_2 end it 'should find no orphans' do - Fabricate(:domain, owner_contact: @contact_1, admin_contacts: [@contact_2]) + Fabricate(:domain, registrant: @contact_1, admin_contacts: [@contact_2]) cc = Contact.count Contact.find_orphans.count.should == 0 Contact.destroy_orphans diff --git a/spec/models/domain_spec.rb b/spec/models/domain_spec.rb index 6307f04cf..bb8881ff1 100644 --- a/spec/models/domain_spec.rb +++ b/spec/models/domain_spec.rb @@ -7,7 +7,7 @@ describe Domain do it { should belong_to(:registrar) } it { should have_many(:nameservers) } - it { should belong_to(:owner_contact) } + it { should belong_to(:registrant) } it { should have_many(:tech_contacts) } it { should have_many(:admin_contacts) } it { should have_many(:domain_transfers) } @@ -156,7 +156,7 @@ describe Domain do # d = Domain.new # expect(d.valid?).to be false # expect(d.errors.messages).to match_array({ - # owner_contact: ['Registrant is missing'], + # registrant: ['Registrant is missing'], # admin_contacts: ['Admin contacts count must be between 1 - infinity'], # nameservers: ['Nameservers count must be between 2-11'], # registrar: ['Registrar is missing'],