Merge pull request #2010 from internetee/domain_version_legacy_id_issue

added fix for contact versions
This commit is contained in:
Timo Võhmar 2021-05-28 16:13:39 +03:00 committed by GitHub
commit 07da360a5a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 3 deletions

View file

@ -67,7 +67,9 @@
- else
- contact = Contact.all_versions_for([domain.registrant_id], version.created_at).first
- if contact.nil? && ver = Version::ContactVersion.where(item_id: domain.registrant_id).last
- contact = Contact.new(ver.object.to_h.merge(ver.object_changes.to_h.each_with_object({}) {|(k,v), o| o[k] = v.last }))
- merged_obj = ver.object_changes.to_h.each_with_object({}) {|(k,v), o| o[k] = v.last }
- result = ver.object.to_h.merge(merged_obj)&.slice(*Contact&.column_names)
- contact = Contact.new(result)
= contact.try(:name)
= " ".html_safe
= "(#{t(:deleted)})"

View file

@ -24,8 +24,9 @@ class ContactVersionsTest < ApplicationSystemTestCase
INSERT INTO log_contacts (item_type, item_id, event, whodunnit, object,
object_changes, created_at, session, children, ident_updated_at, uuid)
VALUES ('Contact', 75, 'update', '1-AdminUser',
'{"id": 75, "code": "test_code", "auth_info": "8b4d462aa04194ca78840a", "registrar_id": #{@registrar.id}, "old_field": "value"}',
'{"other_made_up_field": "value"}',
'{"id": 75, "code": "test_code", "auth_info": "8b4d462aa04194ca78840a", "registrar_id": #{@registrar.id}, "old_field": "value",
"legal_id": "123"}',
'{"other_made_up_field": "value"}',
'2018-04-23 15:50:48.113491', '2018-04-23 12:44:56',
'{"legal_documents":[null]}', null, null
)