From 9623b3e2075310800d15d18d6649f2e392522c36 Mon Sep 17 00:00:00 2001 From: Thiago Youssef Date: Thu, 14 Jul 2022 08:49:41 -0300 Subject: [PATCH] Allow update phone disclose situation with org registrations --- .../api/v1/registrant/contacts_controller.rb | 2 +- .../api/v1/registrant/contacts/update_test.rb | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/app/controllers/api/v1/registrant/contacts_controller.rb b/app/controllers/api/v1/registrant/contacts_controller.rb index b196c567a..86a8dc87d 100644 --- a/app/controllers/api/v1/registrant/contacts_controller.rb +++ b/app/controllers/api/v1/registrant/contacts_controller.rb @@ -62,7 +62,7 @@ module Api disclosed_attributes = reparsed_request_json[:disclosed_attributes] if disclosed_attributes - if disclosed_attributes.present? && contact.org? + if disclosed_attributes.present? && contact.org? && !disclosed_attributes.include?('phone') error_msg = "Legal person's data is visible by default and cannot be concealed." \ ' Please remove this parameter.' render json: { errors: [{ disclosed_attributes: [error_msg] }] }, status: :bad_request diff --git a/test/integration/api/v1/registrant/contacts/update_test.rb b/test/integration/api/v1/registrant/contacts/update_test.rb index d7a3060b6..50618647f 100644 --- a/test/integration/api/v1/registrant/contacts/update_test.rb +++ b/test/integration/api/v1/registrant/contacts/update_test.rb @@ -215,6 +215,20 @@ class RegistrantApiV1ContactUpdateTest < ActionDispatch::IntegrationTest JSON.parse(response.body, symbolize_names: true) end + def test_legal_persons_disclosed_attributes_change_when_phone + @contact = contacts(:acme_ltd) + @contact.update!(disclosed_attributes: %w[]) + + patch api_v1_registrant_contact_path(@contact.uuid), + params: { disclosed_attributes: %w[phone] }, + as: :json, + headers: { 'HTTP_AUTHORIZATION' => auth_token } + @contact.reload + + assert_response :ok + assert_equal %w[phone], @contact.disclosed_attributes + end + def test_return_contact_details patch api_v1_registrant_contact_path(@contact.uuid), params: { name: 'new name' }, as: :json,