|
|
|
|
@ -420,6 +420,36 @@ RSpec.describe Imports::SalesLogsImportService do
|
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
context "and it has an invalid record with invalid contracts exchange date" do |
|
|
|
|
let(:sales_log_id) { "shared_ownership_sales_log" } |
|
|
|
|
|
|
|
|
|
before do |
|
|
|
|
sales_log_xml.at_xpath("//xmlns:DAY").content = "1" |
|
|
|
|
sales_log_xml.at_xpath("//xmlns:MONTH").content = "10" |
|
|
|
|
sales_log_xml.at_xpath("//xmlns:YEAR").content = "2022" |
|
|
|
|
sales_log_xml.at_xpath("//xmlns:EXDAY").content = "1" |
|
|
|
|
sales_log_xml.at_xpath("//xmlns:EXMONTH").content = "4" |
|
|
|
|
sales_log_xml.at_xpath("//xmlns:EXYEAR").content = "2020" |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
it "intercepts the relevant validation error" do |
|
|
|
|
expect(logger).to receive(:warn).with(/Removing exchange date as the exchange date is invalid/) |
|
|
|
|
expect { sales_log_service.send(:create_log, sales_log_xml) } |
|
|
|
|
.not_to raise_error |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
it "clears out the invalid answers" do |
|
|
|
|
allow(logger).to receive(:warn) |
|
|
|
|
|
|
|
|
|
sales_log_service.send(:create_log, sales_log_xml) |
|
|
|
|
sales_log = SalesLog.find_by(old_id: sales_log_id) |
|
|
|
|
|
|
|
|
|
expect(sales_log).not_to be_nil |
|
|
|
|
expect(sales_log.saledate).to eq(Time.zone.local(2022, 10, 1)) |
|
|
|
|
expect(sales_log.exdate).to be_nil |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
context "when inferring default answers for completed sales logs" do |
|
|
|
|
context "when the armedforcesspouse is not answered" do |
|
|
|
|
let(:sales_log_id) { "discounted_ownership_sales_log" } |
|
|
|
|
|