Browse Source

Fix failing sales household validation test

pull/2361/head
Robert Sullivan 2 years ago
parent
commit
e9f9421659
  1. 6
      spec/models/validations/sales/household_validations_spec.rb

6
spec/models/validations/sales/household_validations_spec.rb

@ -316,7 +316,7 @@ RSpec.describe Validations::Sales::HouseholdValidations do
end end
describe "validating fields about buyers living in the property" do describe "validating fields about buyers living in the property" do
let(:sales_log) { FactoryBot.create(:sales_log, :outright_sale_setup_complete, noint: 1, companybuy: 2, buylivein:, jointpur:, jointmore:, buy1livein:) } let(:sales_log) { FactoryBot.create(:sales_log, :outright_sale_setup_complete, saledate: log_date, noint: 1, companybuy: 2, buylivein:, jointpur:, jointmore:, buy1livein:) }
context "when buyers will live in the property and the sale is a joint purchase" do context "when buyers will live in the property and the sale is a joint purchase" do
let(:buylivein) { 1 } let(:buylivein) { 1 }
@ -348,6 +348,9 @@ RSpec.describe Validations::Sales::HouseholdValidations do
expect(sales_log.errors).to be_empty expect(sales_log.errors).to be_empty
end end
context "with 2023 logs" do
let(:log_date) { Time.zone.local(2023, 4, 1) }
it "triggers a validation if buyer two will also not live in the property" do it "triggers a validation if buyer two will also not live in the property" do
sales_log.buy2livein = 2 sales_log.buy2livein = 2
household_validator.validate_buyers_living_in_property(sales_log) household_validator.validate_buyers_living_in_property(sales_log)
@ -356,6 +359,7 @@ RSpec.describe Validations::Sales::HouseholdValidations do
expect(sales_log.errors[:buy1livein]).to include I18n.t("validations.household.buylivein.buyers_will_live_in_property_values_inconsistent") expect(sales_log.errors[:buy1livein]).to include I18n.t("validations.household.buylivein.buyers_will_live_in_property_values_inconsistent")
end end
end end
end
context "and we don't know whether buyer one will live in the property" do context "and we don't know whether buyer one will live in the property" do
let(:buy1livein) { nil } let(:buy1livein) { nil }

Loading…
Cancel
Save