mirror of
https://github.com/internetee/registry.git
synced 2025-07-22 18:56:05 +02:00
Merge remote-tracking branch 'origin/master' into log-bounced-emails
This commit is contained in:
commit
fc34105c40
70 changed files with 791 additions and 4967 deletions
|
@ -0,0 +1,44 @@
|
|||
$VERBOSE=nil
|
||||
require 'test_helper'
|
||||
require 'auth_token/auth_token_creator'
|
||||
|
||||
class RegistrantApiCompaniesTest < ApplicationIntegrationTest
|
||||
def setup
|
||||
super
|
||||
|
||||
@contact = contacts(:john)
|
||||
@user = users(:registrant)
|
||||
@auth_headers = { 'HTTP_AUTHORIZATION' => auth_token }
|
||||
end
|
||||
|
||||
def test_accepts_limit_and_offset_parameters
|
||||
contacts(:william).update!(ident: '1234', ident_type: 'priv', ident_country_code: 'US')
|
||||
|
||||
get '/api/v1/registrant/companies', params: { 'limit' => 1, 'offset' => 0 },
|
||||
headers: @auth_headers
|
||||
response_json = JSON.parse(response.body, symbolize_names: true)
|
||||
assert_equal(200, response.status)
|
||||
assert_equal(1, response_json.values.flatten.count)
|
||||
|
||||
get '/api/v1/registrant/companies', headers: @auth_headers
|
||||
response_json = JSON.parse(response.body, symbolize_names: true)
|
||||
assert_equal(@user.companies.size, response_json.count)
|
||||
end
|
||||
|
||||
def test_format
|
||||
contacts(:william).update!(ident: '1234', ident_type: 'priv', ident_country_code: 'US')
|
||||
get '/api/v1/registrant/companies', headers: @auth_headers
|
||||
response_json = JSON.parse(response.body, symbolize_names: true)
|
||||
assert_equal(1, response_json.count)
|
||||
assert response_json.is_a?(Hash)
|
||||
assert_equal(:companies, response_json.keys.first)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def auth_token
|
||||
token_creator = AuthTokenCreator.create_with_defaults(@user)
|
||||
hash = token_creator.token_in_hash
|
||||
"Bearer #{hash[:access_token]}"
|
||||
end
|
||||
end
|
|
@ -12,7 +12,7 @@ class RegistrantApiContactsTest < ApplicationIntegrationTest
|
|||
|
||||
def test_root_accepts_limit_and_offset_parameters
|
||||
contacts(:william).update!(ident: '1234', ident_type: 'priv', ident_country_code: 'US')
|
||||
assert_equal 4, @user.contacts.size
|
||||
assert_equal 4, @user.contacts(representable: false).size
|
||||
|
||||
get '/api/v1/registrant/contacts', params: { 'limit' => 1, 'offset' => 0 },
|
||||
headers: @auth_headers
|
||||
|
@ -22,7 +22,7 @@ class RegistrantApiContactsTest < ApplicationIntegrationTest
|
|||
|
||||
get '/api/v1/registrant/contacts', headers: @auth_headers
|
||||
response_json = JSON.parse(response.body, symbolize_names: true)
|
||||
assert_equal(@user.contacts.size, response_json.count)
|
||||
assert_equal(@user.contacts(representable: false).size, response_json.count)
|
||||
end
|
||||
|
||||
def test_get_contact_details_by_uuid
|
||||
|
|
|
@ -35,7 +35,7 @@ class RegistrantApiV1ContactListTest < ActionDispatch::IntegrationTest
|
|||
get api_v1_registrant_contacts_path, as: :json, headers: { 'HTTP_AUTHORIZATION' => auth_token }
|
||||
|
||||
response_json = JSON.parse(response.body, symbolize_names: true)
|
||||
assert_equal @user.contacts.count, response_json.size
|
||||
assert_equal @user.contacts(representable: false).count, response_json.size
|
||||
assert_includes response_json.map{ |hash| hash[:code] }, @contact.code
|
||||
end
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue