|
|
|
@ -49,8 +49,12 @@ RSpec.describe Validations::Sales::HouseholdValidations do |
|
|
|
record.relat2 = "P" |
|
|
|
record.relat2 = "P" |
|
|
|
record.relat3 = "P" |
|
|
|
record.relat3 = "P" |
|
|
|
household_validator.validate_household_number_of_other_members(record) |
|
|
|
household_validator.validate_household_number_of_other_members(record) |
|
|
|
expect(record.errors["base"]) |
|
|
|
expect(record.errors["relat2"]) |
|
|
|
.to include(match I18n.t("validations.household.relat.one_partner")) |
|
|
|
.to include(match I18n.t("validations.household.relat.one_partner")) |
|
|
|
|
|
|
|
expect(record.errors["relat3"]) |
|
|
|
|
|
|
|
.to include(match I18n.t("validations.household.relat.one_partner")) |
|
|
|
|
|
|
|
expect(record.errors["relat4"]) |
|
|
|
|
|
|
|
.not_to include(match I18n.t("validations.household.relat.one_partner")) |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
it "expects that a tenant can have a partner" do |
|
|
|
it "expects that a tenant can have a partner" do |
|
|
|
@ -68,38 +72,37 @@ RSpec.describe Validations::Sales::HouseholdValidations do |
|
|
|
expect(record.errors["age2"]).to be_empty |
|
|
|
expect(record.errors["age2"]).to be_empty |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
it "validates that a person under 16 must not be a partner of the buyer" do |
|
|
|
it "validates that a person under 16 must not be a partner of the buyer" |
|
|
|
record.age2 = 14 |
|
|
|
record.age2 = 14 |
|
|
|
record.relat2 = "P" |
|
|
|
record.relat2 = "P" |
|
|
|
household_validator.validate_household_number_of_other_members(record) |
|
|
|
household_validator.validate_household_number_of_other_members(record) |
|
|
|
expect(record.errors["relat2"]) |
|
|
|
expect(record.errors["relat2"]) |
|
|
|
.to include(match I18n.t("validations.household.relat.partner_under_16")) |
|
|
|
.to include(match I18n.t("validations.household.relat.partner_under_16")) |
|
|
|
expect(record.errors["age2"]) |
|
|
|
expect(record.errors["age2"]) |
|
|
|
.to include(match I18n.t("validations.household.age.partner_under_16")) |
|
|
|
.to include(match I18n.t("validations.household.age.partner_under_16")) |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
it "validates that a person over 20 must not be a child of the buyer" do |
|
|
|
it "validates that a person over 20 must not be a child of the buyer" do |
|
|
|
record.age2 = 21 |
|
|
|
record.age2 = 21 |
|
|
|
record.relat2 = "C" |
|
|
|
record.relat2 = "C" |
|
|
|
household_validator.validate_household_number_of_other_members(record) |
|
|
|
household_validator.validate_household_number_of_other_members(record) |
|
|
|
expect(record.errors["relat2"]) |
|
|
|
expect(record.errors["relat2"]) |
|
|
|
.to include(match I18n.t("validations.household.relat.child_over_20")) |
|
|
|
.to include(match I18n.t("validations.household.relat.child_over_20")) |
|
|
|
expect(record.errors["age2"]) |
|
|
|
expect(record.errors["age2"]) |
|
|
|
.to include(match I18n.t("validations.household.age.child_over_20")) |
|
|
|
.to include(match I18n.t("validations.household.age.child_over_20")) |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
it "validates that a person aged 16-19 who is a student must be a child of the buyer" do |
|
|
|
it "validates that a person aged 16-19 who is a student must be a child of the buyer" do |
|
|
|
record.age2 = 18 |
|
|
|
record.age2 = 18 |
|
|
|
record.ecstat2 = "7" |
|
|
|
record.ecstat2 = "7" |
|
|
|
record.relat2 = "P" |
|
|
|
record.relat2 = "P" |
|
|
|
household_validator.validate_household_number_of_other_members(record) |
|
|
|
household_validator.validate_household_number_of_other_members(record) |
|
|
|
expect(record.errors["relat2"]) |
|
|
|
expect(record.errors["relat2"]) |
|
|
|
.to include(match I18n.t("validations.household.relat.student_16_19")) |
|
|
|
.to include(match I18n.t("validations.household.relat.student_16_19")) |
|
|
|
expect(record.errors["age2"]) |
|
|
|
expect(record.errors["age2"]) |
|
|
|
.to include(match I18n.t("validations.household.age.student_16_19")) |
|
|
|
.to include(match I18n.t("validations.household.age.student_16_19")) |
|
|
|
expect(record.errors["ecstat2"]) |
|
|
|
expect(record.errors["ecstat2"]) |
|
|
|
.to include(match I18n.t("validations.household.ecstat.student_16_19")) |
|
|
|
.to include(match I18n.t("validations.household.ecstat.student_16_19")) |
|
|
|
end |
|
|
|
|
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
|