mirror of
https://github.com/internetee/registry.git
synced 2025-06-08 21:54:48 +02:00
Merge branch 'master' of https://github.com/internetee/registry into 1804-upgrade-ui-tests-for-admin-portal-users
This commit is contained in:
commit
db5022ebaf
4 changed files with 36 additions and 3 deletions
|
@ -1,3 +1,9 @@
|
|||
21.01.2021
|
||||
* Registrant API: optimised contact linking [#1807](https://github.com/internetee/registry/pull/1807)
|
||||
|
||||
20.01.2021
|
||||
* Fixed legaldoc assignment issue on registrant confirmation [#1806](https://github.com/internetee/registry/pull/1806)
|
||||
|
||||
14.01.2021
|
||||
* Fixed IDN and punycode support for REPP domain transfer_info request [#1801](https://github.com/internetee/registry/issues/1801)
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@ module Api
|
|||
end
|
||||
|
||||
def show
|
||||
contact = current_user_contacts.find_by(uuid: params[:uuid])
|
||||
contact = representable_contact(params[:uuid])
|
||||
links = params[:links] == 'true'
|
||||
|
||||
if contact
|
||||
|
@ -91,6 +91,22 @@ module Api
|
|||
|
||||
private
|
||||
|
||||
def representable_contact(uuid)
|
||||
country = current_registrant_user.country.alpha2
|
||||
contact = Contact.find_by(uuid: uuid, ident: current_registrant_user.ident,
|
||||
ident_type: 'priv', ident_country_code: country)
|
||||
return contact if contact
|
||||
|
||||
Contact.find_by(uuid: uuid, ident_type: 'org', ident: company_codes,
|
||||
ident_country_code: country)
|
||||
rescue CompanyRegister::NotAvailableError
|
||||
nil
|
||||
end
|
||||
|
||||
def company_codes
|
||||
current_registrant_user.companies.collect(&:registration_number)
|
||||
end
|
||||
|
||||
def current_user_contacts
|
||||
current_registrant_user.contacts(representable: false)
|
||||
rescue CompanyRegister::NotAvailableError
|
||||
|
|
|
@ -360,9 +360,11 @@ class Contact < ApplicationRecord
|
|||
@desc
|
||||
end
|
||||
|
||||
# Limits returned objects to 11
|
||||
def related_domains
|
||||
a = related_domain_descriptions
|
||||
a.keys.map { |d| { name: d, id: a[d][:id], roles: a[d][:roles] } }
|
||||
ids = DomainContact.select(:domain_id).where(contact_id: id).limit(11).map(&:domain_id).uniq
|
||||
res = Domain.where(id: ids).or(Domain.where(registrant_id: id)).select(:name, :uuid).limit(11)
|
||||
res.pluck(:name, :uuid).map { |name, id| { name: name, id: id } }
|
||||
end
|
||||
|
||||
def status_notes_array=(notes)
|
||||
|
|
|
@ -57,6 +57,15 @@ class RegistrantApiContactsTest < ApplicationIntegrationTest
|
|||
assert_equal({ errors: [base: ['Not authorized']] }, json_body)
|
||||
end
|
||||
|
||||
def test_gets_contact_domain_links_when_requested
|
||||
get "/api/v1/registrant/contacts/#{@contact.uuid}?links=true", headers: @auth_headers
|
||||
|
||||
expected_links = @contact.domains.uniq.map { |d| { name: d.name, id: d.uuid }}
|
||||
assert_response :ok
|
||||
response_json = JSON.parse(response.body, symbolize_names: true)
|
||||
|
||||
assert_empty expected_links - response_json[:links]
|
||||
end
|
||||
private
|
||||
|
||||
def auth_token
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue