From b3c07ba229260d9df01b53f1147648fc0b344512 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Meny?= Date: Tue, 19 Jul 2022 13:32:04 +0100 Subject: [PATCH] CLDC-1228: Handles soft validation confirmations (#749) --- app/services/imports/case_logs_import_service.rb | 9 ++++++++- .../imports/case_logs_import_service_spec.rb | 13 +++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/app/services/imports/case_logs_import_service.rb b/app/services/imports/case_logs_import_service.rb index 440eecb13..814acfb43 100644 --- a/app/services/imports/case_logs_import_service.rb +++ b/app/services/imports/case_logs_import_service.rb @@ -207,6 +207,13 @@ module Imports attributes["postcode_full"] = nil end + # Soft validations can become required answers, set them to yes by default + attributes["pregnancy_value_check"] = 0 + attributes["retirement_value_check"] = 0 + attributes["rent_value_check"] = 0 + attributes["net_income_value_check"] = 0 + + # Sets the log creator owner_id = field_value(xml_doc, "meta", "owner-user-id").strip if owner_id.present? attributes["created_by"] = User.find_by(old_user_id: owner_id) @@ -266,7 +273,7 @@ module Imports end def fields_not_present_in_softwire_data - %w[majorrepairs illness_type_0 tshortfall_known] + %w[majorrepairs illness_type_0 tshortfall_known pregnancy_value_check retirement_value_check rent_value_check net_income_value_check] end def check_status_completed(case_log, previous_status) diff --git a/spec/services/imports/case_logs_import_service_spec.rb b/spec/services/imports/case_logs_import_service_spec.rb index 1e6c28739..836d1a45b 100644 --- a/spec/services/imports/case_logs_import_service_spec.rb +++ b/spec/services/imports/case_logs_import_service_spec.rb @@ -216,6 +216,19 @@ RSpec.describe Imports::CaseLogsImportService do end end + context "and the net income soft validation is triggered" do + before do + case_log_xml.at_xpath("//xmlns:Q8a").content = "1 Weekly" + case_log_xml.at_xpath("//xmlns:Q8Money").content = 890.00 + end + + it "completes the log" do + case_log_service.send(:create_log, case_log_xml) + case_log = CaseLog.find_by(old_id: case_log_id) + expect(case_log.status).to eq("completed") + end + end + context "and this is a supported housing log with multiple locations under a scheme" do let(:case_log_id) { "0b4a68df-30cc-474a-93c0-a56ce8fdad3b" }