Refactor common part of the find_or_create_by_x into a private method

This commit is contained in:
Maciej Szlosarczyk 2018-07-23 14:29:16 +03:00
parent 75119aff2e
commit f92ece5467
No known key found for this signature in database
GPG key ID: 41D62D42D3B0D765
3 changed files with 53 additions and 29 deletions

View file

@ -20,6 +20,19 @@ class RegistrantUserTest < ActiveSupport::TestCase
assert_equal('JOHN SMITH', user.username)
end
def test_find_or_create_by_api_data_creates_a_user_after_upcasing_input
user_data = {
ident: '37710100070',
first_name: 'John',
last_name: 'Smith'
}
RegistrantUser.find_or_create_by_api_data(user_data)
user = User.find_by(registrant_ident: 'EE-37710100070')
assert_equal('JOHN SMITH', user.username)
end
def test_find_or_create_by_mid_data_creates_a_user
user_data = OpenStruct.new(user_country: 'EE', user_id_code: '37710100070',
user_givenname: 'JOHN', user_surname: 'SMITH')