Added additional tests to REPP API

This commit is contained in:
Sergei Tsõganov 2022-06-08 12:07:21 +03:00
parent b505de2f0f
commit b502c2779e
21 changed files with 796 additions and 7 deletions

View file

@ -12,7 +12,7 @@ class ReppV1ContactsListTest < ActionDispatch::IntegrationTest
def test_returns_registrar_contacts
get repp_v1_contacts_path, headers: @auth_headers
json = JSON.parse(response.body, symbolize_names: true)
assert_response :ok
assert_equal @user.registrar.contacts.count, json[:data][:count]
@ -21,7 +21,6 @@ class ReppV1ContactsListTest < ActionDispatch::IntegrationTest
assert json[:data][:contacts][0].is_a? String
end
def test_returns_detailed_registrar_contacts
get repp_v1_contacts_path(details: true), headers: @auth_headers
json = JSON.parse(response.body, symbolize_names: true)
@ -52,4 +51,32 @@ class ReppV1ContactsListTest < ActionDispatch::IntegrationTest
assert_equal (@user.registrar.contacts.count - offset), json[:data][:contacts].length
end
def test_returns_detailed_registrar_contacts_by_search_query
search_params = {
ident_type_eq: 'priv',
}
get repp_v1_contacts_path(details: true, q: search_params), headers: @auth_headers
json = JSON.parse(response.body, symbolize_names: true)
assert_response :ok
assert_equal json[:data][:contacts].length, 3
assert json[:data][:contacts][0].is_a? Hash
end
def test_returns_detailed_registrar_contacts_by_sort_query
contact = contacts(:william)
sort_params = {
s: 'name desc',
}
get repp_v1_contacts_path(details: true, q: sort_params), headers: @auth_headers
json = JSON.parse(response.body, symbolize_names: true)
assert_response :ok
assert_equal @user.registrar.contacts.count, json[:data][:count]
assert_equal @user.registrar.contacts.count, json[:data][:contacts].length
assert_equal json[:data][:contacts][0][:code], contact.code
end
end