Browse Source

fix validation and spec

pull/549/head
Dushan Despotovic 3 years ago
parent
commit
7ad289796f
  1. 2
      app/models/validations/tenancy_validations.rb
  2. 1
      spec/models/validations/tenancy_validations_spec.rb

2
app/models/validations/tenancy_validations.rb

@ -34,7 +34,7 @@ module Validations::TenancyValidations
end end
def validate_joint_tenancy(record) def validate_joint_tenancy(record)
if record.hhmemb == 1 && record.joint != 2 if record.hhmemb == 1 && record.joint != 2 && record.collection_start_year == 2022
record.errors.add :joint, I18n.t("validations.tenancy.not_joint") record.errors.add :joint, I18n.t("validations.tenancy.not_joint")
end end
end end

1
spec/models/validations/tenancy_validations_spec.rb

@ -149,6 +149,7 @@ RSpec.describe Validations::TenancyValidations do
describe "joint tenancy validation" do describe "joint tenancy validation" do
context "when the data inputter has said that there is only one member in the household" do context "when the data inputter has said that there is only one member in the household" do
let(:record) { FactoryBot.create(:case_log, startdate: Time.zone.local(2022, 5, 1)) }
let(:expected_error) { I18n.t("validations.tenancy.not_joint") } let(:expected_error) { I18n.t("validations.tenancy.not_joint") }
it "displays an error if the data inputter says the letting is a joint tenancy" do it "displays an error if the data inputter says the letting is a joint tenancy" do

Loading…
Cancel
Save