mirror of
https://github.com/internetee/registry.git
synced 2025-08-01 15:34:41 +02:00
Moved notifications about automatic contact name update to bulk change poll message
This commit is contained in:
parent
e4d56fe576
commit
216048463d
18 changed files with 201 additions and 96 deletions
|
@ -7,34 +7,40 @@ class RegistrantUserCreationTest < ActiveSupport::TestCase
|
|||
first_name: 'JOHN',
|
||||
last_name: 'SMITH'
|
||||
}
|
||||
|
||||
RegistrantUser.find_or_create_by_api_data(user_data)
|
||||
assert_difference 'RegistrantUser.count' do
|
||||
RegistrantUser.find_or_create_by_api_data(user_data)
|
||||
end
|
||||
|
||||
user = User.find_by(registrant_ident: 'EE-37710100070')
|
||||
assert_equal('JOHN SMITH', user.username)
|
||||
end
|
||||
|
||||
def test_find_or_create_by_api_data_creates_a_user_with_original_name
|
||||
def test_find_or_create_by_api_data_updates_a_user_with_existing_ident
|
||||
user_data = {
|
||||
ident: '37710100070',
|
||||
ident: '1234',
|
||||
country_code: 'US',
|
||||
first_name: 'John',
|
||||
last_name: 'Smith'
|
||||
last_name: 'Smith',
|
||||
}
|
||||
assert_no_difference 'RegistrantUser.count' do
|
||||
RegistrantUser.find_or_create_by_api_data(user_data)
|
||||
end
|
||||
|
||||
RegistrantUser.find_or_create_by_api_data(user_data)
|
||||
|
||||
user = User.find_by(registrant_ident: 'EE-37710100070')
|
||||
user = User.find_by(registrant_ident: 'US-1234')
|
||||
assert_equal('John Smith', user.username)
|
||||
end
|
||||
|
||||
def test_updates_related_contacts_name_if_differs_from_e_identity
|
||||
contact = contacts(:john)
|
||||
contact.update(ident: '39708290276', ident_country_code: 'EE')
|
||||
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'
|
||||
last_name: 'Doe',
|
||||
}
|
||||
|
||||
RegistrantUser.find_or_create_by_api_data(user_data)
|
||||
|
@ -42,7 +48,28 @@ class RegistrantUserCreationTest < ActiveSupport::TestCase
|
|||
user = User.find_by(registrant_ident: 'EE-39708290276')
|
||||
assert_equal('John Doe', user.username)
|
||||
|
||||
contact.reload
|
||||
assert_equal user.username, contact.name
|
||||
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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue