From 2ffa2d632b78c6033adfde3bbd1ad6120ab2e962 Mon Sep 17 00:00:00 2001 From: kosiakkatrina <54268893+kosiakkatrina@users.noreply.github.com> Date: Tue, 16 May 2023 12:13:38 +0100 Subject: [PATCH] Set proplen_asked based on proplen answer for 23/24 (#1630) --- .../bulk_upload/sales/year2023/row_parser.rb | 3 +- .../sales/year2023/row_parser_spec.rb | 36 +++++++++++++++++++ 2 files changed, 38 insertions(+), 1 deletion(-) diff --git a/app/services/bulk_upload/sales/year2023/row_parser.rb b/app/services/bulk_upload/sales/year2023/row_parser.rb index d4cf1ec7e..8082db605 100644 --- a/app/services/bulk_upload/sales/year2023/row_parser.rb +++ b/app/services/bulk_upload/sales/year2023/row_parser.rb @@ -806,7 +806,8 @@ private attributes["mortlen"] = mortlen - attributes["proplen"] = proplen + attributes["proplen"] = proplen if proplen&.positive? + attributes["proplen_asked"] = attributes["proplen"]&.present? ? 0 : 1 attributes["jointmore"] = field_15 attributes["staircase"] = field_87 attributes["privacynotice"] = field_29 diff --git a/spec/services/bulk_upload/sales/year2023/row_parser_spec.rb b/spec/services/bulk_upload/sales/year2023/row_parser_spec.rb index 0139e44f6..48a6dab8b 100644 --- a/spec/services/bulk_upload/sales/year2023/row_parser_spec.rb +++ b/spec/services/bulk_upload/sales/year2023/row_parser_spec.rb @@ -789,5 +789,41 @@ RSpec.describe BulkUpload::Sales::Year2023::RowParser do expect(parser.log.soctenant).to be(1) end end + + describe "with living before purchase years for shared ownership more than 0" do + let(:attributes) { setup_section_params.merge({ field_7: "1", field_86: "1" }) } + + it "is sets living before purchase asked to yes and sets the correct living before purchase years" do + expect(parser.log.proplen_asked).to be(0) + expect(parser.log.proplen).to be(1) + end + end + + describe "with living before purchase years for discounted ownership more than 0" do + let(:attributes) { setup_section_params.merge({ field_7: "2", field_115: "1" }) } + + it "is sets living before purchase asked to yes and sets the correct living before purchase years" do + expect(parser.log.proplen_asked).to be(0) + expect(parser.log.proplen).to be(1) + end + end + + describe "with living before purchase years for shared ownership set to 0" do + let(:attributes) { setup_section_params.merge({ field_7: "1", field_86: "0" }) } + + it "is sets living before purchase asked to no" do + expect(parser.log.proplen_asked).to be(1) + expect(parser.log.proplen).to be_nil + end + end + + describe "with living before purchase 0 years for discounted ownership set to 0" do + let(:attributes) { setup_section_params.merge({ field_7: "2", field_115: "0" }) } + + it "is sets living before purchase asked to no" do + expect(parser.log.proplen_asked).to be(1) + expect(parser.log.proplen).to be_nil + end + end end end