mirror of
https://github.com/internetee/registry.git
synced 2025-06-10 06:34:46 +02:00
added tests for api endpoint
This commit is contained in:
parent
d4312caa91
commit
e488c839dd
1 changed files with 33 additions and 1 deletions
|
@ -5,9 +5,10 @@ class RegistrantApiDomainsTest < ApplicationIntegrationTest
|
|||
def setup
|
||||
super
|
||||
|
||||
@domain = domains(:hospital)
|
||||
@domain = domains(:airport)
|
||||
@registrant = @domain.registrant
|
||||
@user = users(:registrant)
|
||||
domains(:metro).tech_domain_contacts.update(contact_id: @registrant.id)
|
||||
@auth_headers = { 'HTTP_AUTHORIZATION' => auth_token }
|
||||
end
|
||||
|
||||
|
@ -57,6 +58,37 @@ class RegistrantApiDomainsTest < ApplicationIntegrationTest
|
|||
assert(array_of_domain_registrars.include?({name: 'Good Names', website: nil}))
|
||||
end
|
||||
|
||||
def test_return_domain_list_with_registrants_and_admins
|
||||
domains(:hospital).admin_domain_contacts.update(contact_id: contacts(:william).id)
|
||||
domains(:hospital).update(registrant: contacts(:william).becomes(Registrant))
|
||||
|
||||
get '/api/v1/registrant/domains', headers: @auth_headers, params: { 'offset' => 0 }
|
||||
assert_equal(200, response.status)
|
||||
|
||||
response_json = JSON.parse(response.body, symbolize_names: true)
|
||||
response_json[:domains].each do |x|
|
||||
if x[:registrant][:org] == false
|
||||
x[:tech_contacts].each do |s|
|
||||
assert_not s[:name].include?(@registrant.name)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def test_return_domain_list_with_registrants_and_admins_tech
|
||||
get '/api/v1/registrant/domains', headers: @auth_headers, params: { 'offset' => 0, 'tech' => true }
|
||||
assert_equal(200, response.status)
|
||||
|
||||
response_json = JSON.parse(response.body, symbolize_names: true)
|
||||
response_json[:domains].each do |x|
|
||||
if x[:name] == 'metro.test'
|
||||
x[:tech_contacts].each do |s|
|
||||
assert s[:name].include?(@registrant.name)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def test_root_accepts_limit_and_offset_parameters
|
||||
get '/api/v1/registrant/domains', params: { 'limit' => 2, 'offset' => 0 },
|
||||
headers: @auth_headers
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue