Browse Source

Set default hhregresstill

pull/1450/head
Kat 3 years ago
parent
commit
84f09a412b
  1. 1
      app/services/imports/sales_logs_import_service.rb
  2. 25
      spec/services/imports/sales_logs_import_service_spec.rb

1
app/services/imports/sales_logs_import_service.rb

@ -504,6 +504,7 @@ module Imports
def set_default_values(attributes) def set_default_values(attributes)
attributes["armedforcesspouse"] ||= 7 attributes["armedforcesspouse"] ||= 7
attributes["hhregres"] ||= 8 attributes["hhregres"] ||= 8
attributes["hhregresstill"] ||= 7 if attributes["hhregres"] == 1
attributes["disabled"] ||= 3 attributes["disabled"] ||= 3
attributes["wheel"] ||= 3 attributes["wheel"] ||= 3
attributes["hb"] ||= 4 attributes["hb"] ||= 4

25
spec/services/imports/sales_logs_import_service_spec.rb

@ -735,6 +735,31 @@ RSpec.describe Imports::SalesLogsImportService do
end end
end end
context "when inferring armed forces still" do
let(:sales_log_id) { "discounted_ownership_sales_log" }
before do
sales_log_xml.at_xpath("//xmlns:ArmedF").content = "1 Yes"
allow(logger).to receive(:warn).and_return(nil)
end
it "sets hhregresstill to don't know if not answered" do
sales_log_xml.at_xpath("//xmlns:LeftArmedF").content = ""
sales_log_service.send(:create_log, sales_log_xml)
sales_log = SalesLog.find_by(old_id: sales_log_id)
expect(sales_log&.hhregresstill).to eq(7)
end
it "sets hhregresstill correctly if answered" do
sales_log_xml.at_xpath("//xmlns:LeftArmedF").content = "4"
sales_log_service.send(:create_log, sales_log_xml)
sales_log = SalesLog.find_by(old_id: sales_log_id)
expect(sales_log&.hhregresstill).to eq(4)
end
end
context "when inferring disability" do context "when inferring disability" do
let(:sales_log_id) { "discounted_ownership_sales_log" } let(:sales_log_id) { "discounted_ownership_sales_log" }

Loading…
Cancel
Save