mirror of
https://github.com/internetee/registry.git
synced 2025-07-21 10:16:01 +02:00
Clone owner contact if contact has more domains
This commit is contained in:
parent
568121ddd0
commit
33f7920ad8
4 changed files with 16 additions and 4 deletions
5
Gemfile
5
Gemfile
|
@ -13,7 +13,7 @@ gem 'pg', '~> 0.18.0'
|
||||||
gem 'ransack', '~> 1.5.1' # for searching
|
gem 'ransack', '~> 1.5.1' # for searching
|
||||||
# with polymorphic fix
|
# with polymorphic fix
|
||||||
gem 'paper_trail',
|
gem 'paper_trail',
|
||||||
github: 'airblade/paper_trail',
|
github: 'airblade/paper_trail',
|
||||||
ref: 'a453811226ec4ea59753ba6b827e390ced2fc140' # '~> 4.0.0.beta2' # archiving
|
ref: 'a453811226ec4ea59753ba6b827e390ced2fc140' # '~> 4.0.0.beta2' # archiving
|
||||||
gem 'rails-settings-cached', '~> 0.4.1' # for settings
|
gem 'rails-settings-cached', '~> 0.4.1' # for settings
|
||||||
gem 'delayed_job_active_record', '~> 4.0.3' # delayed job
|
gem 'delayed_job_active_record', '~> 4.0.3' # delayed job
|
||||||
|
@ -60,6 +60,9 @@ gem 'newrelic_rpm', '~> 3.9.9.275'
|
||||||
# country listing
|
# country listing
|
||||||
gem 'countries', '~> 0.10.0'
|
gem 'countries', '~> 0.10.0'
|
||||||
|
|
||||||
|
# cloning activerecord objects
|
||||||
|
gem 'deep_cloneable', '~> 2.1.1'
|
||||||
|
|
||||||
group :development do
|
group :development do
|
||||||
# dev tools
|
# dev tools
|
||||||
gem 'spring', '~> 1.2.0'
|
gem 'spring', '~> 1.2.0'
|
||||||
|
|
|
@ -122,6 +122,8 @@ GEM
|
||||||
daemons (1.1.9)
|
daemons (1.1.9)
|
||||||
database_cleaner (1.3.0)
|
database_cleaner (1.3.0)
|
||||||
debug_inspector (0.0.2)
|
debug_inspector (0.0.2)
|
||||||
|
deep_cloneable (2.1.1)
|
||||||
|
activerecord (>= 3.1.0, < 5.0.0)
|
||||||
delayed_job (4.0.6)
|
delayed_job (4.0.6)
|
||||||
activesupport (>= 3.0, < 5.0)
|
activesupport (>= 3.0, < 5.0)
|
||||||
delayed_job_active_record (4.0.3)
|
delayed_job_active_record (4.0.3)
|
||||||
|
@ -455,6 +457,7 @@ DEPENDENCIES
|
||||||
countries (~> 0.10.0)
|
countries (~> 0.10.0)
|
||||||
daemons (~> 1.1.9)
|
daemons (~> 1.1.9)
|
||||||
database_cleaner (~> 1.3.0)
|
database_cleaner (~> 1.3.0)
|
||||||
|
deep_cloneable (~> 2.1.1)
|
||||||
delayed_job_active_record (~> 4.0.3)
|
delayed_job_active_record (~> 4.0.3)
|
||||||
devise (~> 3.4.1)
|
devise (~> 3.4.1)
|
||||||
epp (~> 1.4.0)
|
epp (~> 1.4.0)
|
||||||
|
|
|
@ -401,8 +401,14 @@ class Epp::Domain < Domain
|
||||||
end
|
end
|
||||||
|
|
||||||
def transfer_contacts(current_user)
|
def transfer_contacts(current_user)
|
||||||
if owner_contact.domains.count > 1
|
if owner_contact.domains_owned.count > 1
|
||||||
# create new
|
c = Contact.find(owner_contact_id)
|
||||||
|
oc = c.deep_clone include: [:statuses, :address]
|
||||||
|
oc.code = nil
|
||||||
|
oc.registrar_id = current_user.registrar_id
|
||||||
|
oc.save!
|
||||||
|
|
||||||
|
self.owner_contact_id = oc.id
|
||||||
else
|
else
|
||||||
# transfer contact
|
# transfer contact
|
||||||
# TODO: This is a workaround so Bullet won't complain about n+1 query
|
# TODO: This is a workaround so Bullet won't complain about n+1 query
|
||||||
|
|
|
@ -914,7 +914,7 @@ describe 'EPP Domain', epp: true do
|
||||||
end
|
end
|
||||||
|
|
||||||
# all domain contacts should be under registrar2 now
|
# all domain contacts should be under registrar2 now
|
||||||
domain.owner_contact.reload
|
domain.reload
|
||||||
domain.owner_contact.registrar_id.should == @registrar2.id
|
domain.owner_contact.registrar_id.should == @registrar2.id
|
||||||
# owner_contact should be a new record
|
# owner_contact should be a new record
|
||||||
domain.owner_contact.id.should_not == original_oc_id
|
domain.owner_contact.id.should_not == original_oc_id
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue