Merge branch 'master' of github.com:domify/registry

Conflicts:
	app/models/contact.rb
This commit is contained in:
Martin Lensment 2015-07-27 16:14:41 +03:00
commit 4081cebe73
8 changed files with 25 additions and 18 deletions

View file

@ -43,7 +43,8 @@ class EppController < ApplicationController
if Rails.env.test? || Rails.env.development?
# rubocop:disable Rails/Output
puts e.backtrace.reverse.join("\n")
puts "\nFROM-EPP-RESCUE: #{e.message}\n"
puts "\n BACKTRACE REVERSED!\n"
puts "\n FROM-EPP-RESCUE: #{e.message}\n\n\n"
# rubocop:enable Rails/Output
else
logger.error "FROM-EPP-RESCUE: #{e.message}"

View file

@ -9,7 +9,7 @@ class Contact < ActiveRecord::Base
has_many :registrant_domains, class_name: 'Domain', foreign_key: 'registrant_id' # when contant is registrant
# TODO: remove later
has_many :depricated_statuses, class_name: 'DepricatedContactStatus', dependent: :destroy
has_many :depricated_statuses, class_name: 'DepricatedContactStatus', dependent: :destroy
accepts_nested_attributes_for :legal_documents
@ -30,7 +30,7 @@ class Contact < ActiveRecord::Base
validate :ident_valid_format?
validate :uniq_statuses?
after_initialize do
after_initialize do
self.statuses = [] if statuses.nil?
self.status_notes = {} if status_notes.nil?
end
@ -51,6 +51,9 @@ class Contact < ActiveRecord::Base
manage_ok
end
# for overwrite when doing children loop
attr_writer :domains_present
scope :current_registrars, ->(id) { where(registrar_id: id) }
BIC = 'bic'
@ -113,12 +116,12 @@ class Contact < ActiveRecord::Base
# "pendingUpdate" status MUST NOT be combined with either
# "clientUpdateProhibited" or "serverUpdateProhibited" status.
PENDING_UPDATE = 'pendingUpdate'
# "pendingDelete" MUST NOT be combined with either
# "pendingDelete" MUST NOT be combined with either
# "clientDeleteProhibited" or "serverDeleteProhibited" status.
PENDING_DELETE = 'pendingDelete'
PENDING_DELETE = 'pendingDelete'
STATUSES = [
CLIENT_DELETE_PROHIBITED, SERVER_DELETE_PROHIBITED,
CLIENT_DELETE_PROHIBITED, SERVER_DELETE_PROHIBITED,
CLIENT_TRANSFER_PROHIBITED,
SERVER_TRANSFER_PROHIBITED, CLIENT_UPDATE_PROHIBITED, SERVER_UPDATE_PROHIBITED,
OK, PENDING_CREATE, PENDING_DELETE, PENDING_TRANSFER,
@ -132,7 +135,7 @@ class Contact < ActiveRecord::Base
SERVER_STATUSES = [
SERVER_UPDATE_PROHIBITED,
SERVER_DELETE_PROHIBITED,
SERVER_DELETE_PROHIBITED,
SERVER_TRANSFER_PROHIBITED
]
#
@ -306,18 +309,13 @@ class Contact < ActiveRecord::Base
end
end
# optimization under children loop,
# optimization under children loop,
# otherwise bullet will not be happy
def domains_present?
return @domains_present if @domains_present
domain_contacts.present? || registrant_domains.present?
end
# for overwrite when doing children loop
def domains_present=(boolean)
@domains_present = boolean
end
def manage_linked
if domains_present?
set_linked

View file

@ -528,7 +528,7 @@ class Epp::Domain < Domain
return if registrant.registrar_id == registrar_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
if registrant.registrant_domains.count > 1 || is_other_domains_contact
oc = copy_and_transfer_contact(registrant_id, registrar_id)
self.registrant_id = oc.id
else

View file

@ -8,7 +8,7 @@
%th{class: 'col-xs-4'}= t(:registrar)
%th{class: 'col-xs-4'}= t(:valid_to)
%tbody
- @contact.domains_owned.each do |x|
- @contact.registrant_domains.each do |x|
%tr
%td= link_to(x.name, [:admin, x])
%td= link_to(x.registrar, [:admin, x.registrar])

View file

@ -3,7 +3,7 @@ Fabricator(:domain) do
valid_to Date.new(2014, 8, 7)
period 1
period_unit 'y'
registrant(fabricator: :registrant)
registrant { Fabricate(:registrant) }
nameservers(count: 3)
admin_domain_contacts(count: 1) { Fabricate(:admin_domain_contact) }
tech_domain_contacts(count: 1) { Fabricate(:tech_domain_contact) }

View file

@ -29,6 +29,7 @@ describe ContactMailer do
before :all do
@domain = Fabricate(:domain)
@contact = @domain.registrant
@contact.reload # until figured out why registrant_domains not loaded
@contact.deliver_emails = true
@contact.email = 'test@example.org' # new email
@mail = ContactMailer.email_updated(@contact)

View file

@ -137,8 +137,8 @@ describe Contact do
end
end
it 'should not have relation' do
@contact.relations_with_domain?.should == false
it 'should not have relation with domains' do
@contact.domains_present?.should == false
end
it 'bic should be valid' do
@ -234,9 +234,15 @@ describe Contact do
it 'should have related domain descriptions hash' do
contact = @domain.registrant
contact.reload # somehow it registrant_domains are empty?
contact.related_domain_descriptions.should == { "#{@domain.name}" => [:registrant] }
end
it 'should have related domain descriptions hash when find directly' do
contact = @domain.registrant
Contact.find(contact.id).related_domain_descriptions.should == { "#{@domain.name}" => [:registrant] }
end
it 'should have related domain descriptions hash' do
contact = @domain.contacts.first
contact.related_domain_descriptions.should == { "#{@domain.name}" => [:admin] }

View file

@ -48,6 +48,7 @@ def create_settings
Setting.client_side_status_editing_enabled = true
# speedup and easier to create fabrications
@fixed_registrar =
Registrar.find_by_name('fixed registrar') ||
Fabricate(:registrar, name: 'fixed registrar', code: 'FIXED')