Browse Source

Add intermediate rent error

pull/2053/head
Kat 3 years ago
parent
commit
4e10173c60
  1. 8
      app/services/bulk_upload/lettings/year2023/row_parser.rb
  2. 9
      spec/services/bulk_upload/lettings/year2023/row_parser_spec.rb

8
app/services/bulk_upload/lettings/year2023/row_parser.rb

@ -353,6 +353,14 @@ class BulkUpload::Lettings::Year2023::RowParser
}, },
on: :after_log on: :after_log
validates :field_11,
presence: {
if: proc { renttype == :intermediate },
message: I18n.t("validations.not_answered", question: "intermediate rent type"),
category: :setup,
},
on: :after_log
validates :field_46, format: { with: /\A\d{1,3}\z|\AR\z/, message: "Age of person 1 must be a number or the letter R" }, on: :after_log validates :field_46, format: { with: /\A\d{1,3}\z|\AR\z/, message: "Age of person 1 must be a number or the letter R" }, on: :after_log
validates :field_52, format: { with: /\A\d{1,3}\z|\AR\z/, message: "Age of person 2 must be a number or the letter R" }, allow_blank: true, on: :after_log validates :field_52, format: { with: /\A\d{1,3}\z|\AR\z/, message: "Age of person 2 must be a number or the letter R" }, allow_blank: true, on: :after_log
validates :field_56, format: { with: /\A\d{1,3}\z|\AR\z/, message: "Age of person 3 must be a number or the letter R" }, allow_blank: true, on: :after_log validates :field_56, format: { with: /\A\d{1,3}\z|\AR\z/, message: "Age of person 3 must be a number or the letter R" }, allow_blank: true, on: :after_log

9
spec/services/bulk_upload/lettings/year2023/row_parser_spec.rb

@ -809,6 +809,15 @@ RSpec.describe BulkUpload::Lettings::Year2023::RowParser do
end end
end end
context "when intermediate rent and field_11 (Which type of Intermediate Rent) is not given" do
let(:attributes) { { bulk_upload:, field_5: "9", field_11: nil } }
it "adds error on field_11" do
expect(parser.errors[:field_5]).to be_present
expect(parser.errors[:field_11]).to eq(["You must answer intermediate rent type"])
end
end
context "when bulk upload is for general needs" do context "when bulk upload is for general needs" do
context "when general needs option selected" do context "when general needs option selected" do
let(:attributes) { { bulk_upload:, field_5: "1", field_4: "1" } } let(:attributes) { { bulk_upload:, field_5: "1", field_4: "1" } }

Loading…
Cancel
Save