@ -1310,6 +1310,87 @@ RSpec.describe Imports::LettingsLogsImportService do
end
end
context " when this is a renewal and layear is just moved to local authority " do
let ( :lettings_log_id ) { " 0ead17cb-1668-442d-898c-0d52879ff592 " }
let ( :lettings_log_file ) { open_file ( fixture_directory , lettings_log_id ) }
let ( :lettings_log_xml ) { Nokogiri :: XML ( lettings_log_file ) }
before do
lettings_log_xml . at_xpath ( " //xmlns:DAY " ) . content = " 10 "
lettings_log_xml . at_xpath ( " //xmlns:MONTH " ) . content = " 10 "
lettings_log_xml . at_xpath ( " //xmlns:YEAR " ) . content = " 2022 "
lettings_log_xml . at_xpath ( " //xmlns:Q27 " ) . content = " 14 "
lettings_log_xml . at_xpath ( " //xmlns:Q12c " ) . content = " 1 "
lettings_log_xml . at_xpath ( " //xmlns:Q26 " ) . content = " 1 "
lettings_log_xml . at_xpath ( " //xmlns:MRCDAY " ) . content = " "
lettings_log_xml . at_xpath ( " //xmlns:MRCMONTH " ) . content = " "
lettings_log_xml . at_xpath ( " //xmlns:MRCYEAR " ) . content = " "
lettings_log_xml . at_xpath ( " //xmlns:VDAY " ) . content = " 10 "
lettings_log_xml . at_xpath ( " //xmlns:VMONTH " ) . content = " 10 "
lettings_log_xml . at_xpath ( " //xmlns:VYEAR " ) . content = " 2022 "
lettings_log_xml . at_xpath ( " //xmlns:P1Nat " ) . content = " "
lettings_log_xml . at_xpath ( " //xmlns:Q9a " ) . content = " "
lettings_log_xml . at_xpath ( " //xmlns:Q11 " ) . content = " 32 "
lettings_log_xml . at_xpath ( " //xmlns:Q16 " ) . content = " 1 "
end
it " intercepts the relevant validation error " do
expect ( logger ) . to receive ( :warn ) . with ( / Removing layear with error: The household cannot have just moved to the local authority area if this letting is a renewal / )
expect { lettings_log_service . send ( :create_log , lettings_log_xml ) }
. not_to raise_error
end
it " clears out the layear answer " do
allow ( logger ) . to receive ( :warn )
lettings_log_service . send ( :create_log , lettings_log_xml )
lettings_log = LettingsLog . find_by ( old_id : lettings_log_id )
expect ( lettings_log ) . not_to be_nil
expect ( lettings_log . layear ) . to be_nil
end
end
context " when this is a void date is after major repairs day " do
let ( :lettings_log_id ) { " 0ead17cb-1668-442d-898c-0d52879ff592 " }
let ( :lettings_log_file ) { open_file ( fixture_directory , lettings_log_id ) }
let ( :lettings_log_xml ) { Nokogiri :: XML ( lettings_log_file ) }
before do
lettings_log_xml . at_xpath ( " //xmlns:DAY " ) . content = " 10 "
lettings_log_xml . at_xpath ( " //xmlns:MONTH " ) . content = " 10 "
lettings_log_xml . at_xpath ( " //xmlns:YEAR " ) . content = " 2022 "
# lettings_log_xml.at_xpath("//xmlns:Q12c").content = "1"
# lettings_log_xml.at_xpath("//xmlns:Q26").content = "1"
lettings_log_xml . at_xpath ( " //xmlns:MRCDAY " ) . content = " 9 "
lettings_log_xml . at_xpath ( " //xmlns:MRCMONTH " ) . content = " 9 "
lettings_log_xml . at_xpath ( " //xmlns:MRCYEAR " ) . content = " 2021 "
lettings_log_xml . at_xpath ( " //xmlns:VDAY " ) . content = " 10 "
lettings_log_xml . at_xpath ( " //xmlns:VMONTH " ) . content = " 10 "
lettings_log_xml . at_xpath ( " //xmlns:VYEAR " ) . content = " 2021 "
# lettings_log_xml.at_xpath("//xmlns:P1Nat").content = ""
# lettings_log_xml.at_xpath("//xmlns:Q9a").content = ""
# lettings_log_xml.at_xpath("//xmlns:Q11").content = "32"
# lettings_log_xml.at_xpath("//xmlns:Q16").content = "1"
end
it " intercepts the relevant validation error " do
expect ( logger ) . to receive ( :warn ) . with ( / Removing layear with error: The household cannot have just moved to the local authority area if this letting is a renewal / )
expect { lettings_log_service . send ( :create_log , lettings_log_xml ) }
. not_to raise_error
end
it " clears out the layear answer " do
allow ( logger ) . to receive ( :warn )
lettings_log_service . send ( :create_log , lettings_log_xml )
lettings_log = LettingsLog . find_by ( old_id : lettings_log_id )
expect ( lettings_log ) . not_to be_nil
expect ( lettings_log . layear ) . to be_nil
end
end
context " and the earnings is not a whole number " do
let ( :lettings_log_id ) { " 00d2343e-d5fa-4c89-8400-ec3854b0f2b4 " }
let ( :lettings_log_file ) { open_file ( fixture_directory , lettings_log_id ) }