|
|
|
@ -674,18 +674,45 @@ RSpec.describe Validations::HouseholdValidations do |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
describe "housing needs validations" do |
|
|
|
describe "housing needs validations" do |
|
|
|
it "is invalid when a combination of housingneeds == 1 (yes) && housingneeds_type == 3 (none of listed) && housingneeds_other == 0 (no)" do |
|
|
|
context "with housingneeds == 2 (yes) && housingneeds_type == 3" do |
|
|
|
record.housingneeds = 1 |
|
|
|
before do |
|
|
|
record.housingneeds_type = 3 |
|
|
|
record.housingneeds = 1 |
|
|
|
record.housingneeds_other = 0 |
|
|
|
record.housingneeds_type = 3 |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
context "with housingneeds_other == 0 (no)" do |
|
|
|
|
|
|
|
before do |
|
|
|
|
|
|
|
record.housingneeds_other = 0 |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
it "is invalid" do |
|
|
|
|
|
|
|
household_validator.validate_combination_of_housing_needs_responses(record) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
error_message = ["If somebody in the household has disabled access needs, they must have the access needs listed, or other access needs"] |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
expect(record.errors["housingneeds"]).to eq(error_message) |
|
|
|
|
|
|
|
expect(record.errors["housingneeds_type"]).to eq(error_message) |
|
|
|
|
|
|
|
expect(record.errors["housingneeds_other"]).to eq(error_message) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
context "with housingneeds_other == 2 (don't know)" do |
|
|
|
|
|
|
|
before do |
|
|
|
|
|
|
|
record.housingneeds_other = 2 |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
household_validator.validate_combination_of_housing_needs_responses(record) |
|
|
|
it "is invalid" do |
|
|
|
|
|
|
|
household_validator.validate_combination_of_housing_needs_responses(record) |
|
|
|
|
|
|
|
|
|
|
|
error_message = ["If somebody in the household has disabled access needs, they must have the access needs listed, or other access needs"] |
|
|
|
error_message = ["If somebody in the household has disabled access needs, they must have the access needs listed, or other access needs"] |
|
|
|
|
|
|
|
|
|
|
|
expect(record.errors["housingneeds"]).to eq(error_message) |
|
|
|
expect(record.errors["housingneeds"]).to eq(error_message) |
|
|
|
expect(record.errors["housingneeds_type"]).to eq(error_message) |
|
|
|
expect(record.errors["housingneeds_type"]).to eq(error_message) |
|
|
|
expect(record.errors["housingneeds_other"]).to eq(error_message) |
|
|
|
expect(record.errors["housingneeds_other"]).to eq(error_message) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
|