diff --git a/app/services/ccms/parsers/applicant_search_response_parser.rb b/app/services/ccms/parsers/applicant_search_response_parser.rb index 7da4dc767ce..94b28003b4a 100644 --- a/app/services/ccms/parsers/applicant_search_response_parser.rb +++ b/app/services/ccms/parsers/applicant_search_response_parser.rb @@ -67,9 +67,9 @@ def build_client_result_array def parse_client(client_struct) client_struct.match = [ - @applicant.first_name.gsub(/[’‘]/, CCMS::Requestors::BaseRequestor::CHARACTERS).first.casecmp?(client_struct.first_initial), - @applicant.last_name.gsub(/[’‘]/, CCMS::Requestors::BaseRequestor::CHARACTERS).casecmp?(client_struct.last_name), - @applicant.surname_at_birth.gsub(/[’‘]/, CCMS::Requestors::BaseRequestor::CHARACTERS).casecmp?(client_struct.last_name_at_birth), + @applicant.first_name.gsub(/[’‘]/, CCMS::Requestors::BaseRequestor::SPECIAL_CHARACTER_REPLACEMENTS).first.casecmp?(client_struct.first_initial), + @applicant.last_name.gsub(/[’‘]/, CCMS::Requestors::BaseRequestor::SPECIAL_CHARACTER_REPLACEMENTS).casecmp?(client_struct.last_name), + @applicant.surname_at_birth.gsub(/[’‘]/, CCMS::Requestors::BaseRequestor::SPECIAL_CHARACTER_REPLACEMENTS).casecmp?(client_struct.last_name_at_birth), @applicant.date_of_birth.strftime("%Y-%m-%d").eql?(client_struct.date_of_birth), (@applicant.national_insurance_number || "").casecmp?(client_struct.national_insurance_number), ].all? diff --git a/app/services/ccms/requestors/base_requestor.rb b/app/services/ccms/requestors/base_requestor.rb index a54b9fe6915..a7767939eb0 100644 --- a/app/services/ccms/requestors/base_requestor.rb +++ b/app/services/ccms/requestors/base_requestor.rb @@ -18,9 +18,9 @@ class BaseRequestor "xmlns:xsi" => "http://www.w3.org/2001/XMLSchema-instance", }.freeze - CHARACTERS = { - "’" => "'", - "‘" => "'", + SPECIAL_CHARACTER_REPLACEMENTS = { + "‘" => "'", # opening curly quote + "’" => "'", # closing curly quote }.freeze attr_reader :namespaces @@ -41,7 +41,7 @@ def formatted_xml result = "" formatter = REXML::Formatters::Pretty.new formatter.compact = true - formatter.write(REXML::Document.new(request_xml.gsub(/[’‘]/, CHARACTERS)), result) + formatter.write(REXML::Document.new(request_xml.gsub(/[’‘]/, SPECIAL_CHARACTER_REPLACEMENTS)), result) result end