From f4401869de9c37e4a93a9433fa1415cd107b7dec Mon Sep 17 00:00:00 2001 From: Dushan <47317567+dushan-madetech@users.noreply.github.com> Date: Wed, 4 May 2022 14:48:07 +0100 Subject: [PATCH] Age known believe import fixes (#545) * amend fixture to make test fail * fix failing test * lint fixes --- app/services/imports/case_logs_import_service.rb | 13 ++++++++----- .../0ead17cb-1668-442d-898c-0d52879ff592.xml | 4 ++-- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/app/services/imports/case_logs_import_service.rb b/app/services/imports/case_logs_import_service.rb index 22b9f3c99..37c6277e7 100644 --- a/app/services/imports/case_logs_import_service.rb +++ b/app/services/imports/case_logs_import_service.rb @@ -345,11 +345,14 @@ module Imports return nil if hhmemb.present? && index > hhmemb age_refused = string_or_nil(xml_doc, "P#{index}AR") - if age_refused == "AGE_REFUSED" - 1 # No - else - 0 # Yes + if age_refused.present? + if age_refused.casecmp("AGE_REFUSED").zero? + return 1 # No + else + return 0 # Yes + end end + 0 end def details_known(index, attributes) @@ -501,7 +504,7 @@ module Imports end def people_with_details(xml_doc) - ((2..8).map { |x| string_or_nil(xml_doc, "P#{x}Rel") } + [string_or_nil(xml_doc, "P1Age")]).compact + ((2..8).map { |x| string_or_nil(xml_doc, "P#{x}Rel") } + [string_or_nil(xml_doc, "P1Sex")]).compact end end end diff --git a/spec/fixtures/softwire_imports/case_logs/0ead17cb-1668-442d-898c-0d52879ff592.xml b/spec/fixtures/softwire_imports/case_logs/0ead17cb-1668-442d-898c-0d52879ff592.xml index 3ff204058..ac7ef6d5a 100644 --- a/spec/fixtures/softwire_imports/case_logs/0ead17cb-1668-442d-898c-0d52879ff592.xml +++ b/spec/fixtures/softwire_imports/case_logs/0ead17cb-1668-442d-898c-0d52879ff592.xml @@ -48,8 +48,8 @@ <_2cYears/> - 23 - + + Age_Refused Female 6) Not Seeking Work 17 Refused