Modifications for updating business and private contacts

This commit is contained in:
Sergei Tsõganov 2022-03-29 10:39:26 +03:00
parent 4afd32ebff
commit eb64b3aca4
10 changed files with 159 additions and 163 deletions

View file

@ -29,47 +29,4 @@ class RegistrantUserCreationTest < ActiveSupport::TestCase
user = User.find_by(registrant_ident: 'US-1234')
assert_equal('John Smith', user.username)
end
def test_updates_related_contacts_name_if_different_from_e_identity
registrars = [registrars(:bestnames), registrars(:goodnames)]
contacts = [contacts(:john), contacts(:william), contacts(:identical_to_william)]
contacts.each do |c|
c.update(ident: '39708290276', ident_country_code: 'EE')
end
user_data = {
ident: '39708290276',
first_name: 'John',
last_name: 'Doe',
}
RegistrantUser.find_or_create_by_api_data(user_data)
user = User.find_by(registrant_ident: 'EE-39708290276')
assert_equal('John Doe', user.username)
contacts.each do |c|
c.reload
assert_equal user.username, c.name
assert user.actions.find_by(operation: :update, contact_id: c.id)
end
bulk_action = BulkAction.find_by(user_id: user.id, operation: :bulk_update)
assert_equal 2, bulk_action.subactions.size
registrars.each do |r|
notification = r.notifications.unread.order('created_at DESC').take
if r == registrars(:bestnames)
assert_equal '2 contacts have been updated by registrant', notification.text
assert_equal 'BulkAction', notification.attached_obj_type
assert_equal bulk_action.id, notification.attached_obj_id
assert_equal bulk_action.id, notification.action_id
else
assert_equal 'Contact william-002 has been updated by registrant', notification.text
refute notification.action_id
refute notification.attached_obj_id
refute notification.attached_obj_type
end
end
end
end