From 3434b18b2870ed5b850fdc61f9d200fee9e05542 Mon Sep 17 00:00:00 2001 From: Dushan Despotovic Date: Wed, 11 May 2022 17:02:42 +0100 Subject: [PATCH] fix failures --- .../validations/household_validations.rb | 22 ------------ spec/features/form/validations_spec.rb | 2 +- spec/fixtures/exports/case_logs.xml | 1 + spec/fixtures/forms/2021_2022.json | 16 ++++++--- .../interruption_screen_helper_spec.rb | 6 ++-- .../validations/household_validations_spec.rb | 35 ------------------- 6 files changed, 17 insertions(+), 65 deletions(-) diff --git a/app/models/validations/household_validations.rb b/app/models/validations/household_validations.rb index a48f775dc..4c0fec16f 100644 --- a/app/models/validations/household_validations.rb +++ b/app/models/validations/household_validations.rb @@ -146,10 +146,6 @@ private economic_status = record.public_send("ecstat#{person_num}") return unless age && economic_status - # if age > 70 && !tenant_is_retired?(economic_status) - # record.errors.add "ecstat#{person_num}", I18n.t("validations.household.ecstat.retired_over_70", person_num:) - # record.errors.add "age#{person_num}", I18n.t("validations.household.age.retired_over_70", person_num:) - # end if age < 16 && !tenant_is_economic_child?(economic_status) record.errors.add "ecstat#{person_num}", I18n.t("validations.household.ecstat.child_under_16", person_num:) record.errors.add "age#{person_num}", I18n.t("validations.household.age.child_under_16", person_num:) @@ -184,24 +180,6 @@ private end end - # def validate_person_age_and_gender_match_economic_status(record, person_num) - # age = record.public_send("age#{person_num}") - # gender = record.public_send("sex#{person_num}") - # economic_status = record.public_send("ecstat#{person_num}") - # return unless age && economic_status && gender - # - # if gender == "M" && tenant_is_retired?(economic_status) && age < 65 - # record.errors.add "age#{person_num}", I18n.t("validations.household.age.retired_male") - # record.errors.add "sex#{person_num}", I18n.t("validations.household.gender.retired_male") - # record.errors.add "ecstat#{person_num}", I18n.t("validations.household.ecstat.retired_male") - # end - # if gender == "F" && tenant_is_retired?(economic_status) && age < 60 - # record.errors.add "age#{person_num}", I18n.t("validations.household.age.retired_female") - # record.errors.add "sex#{person_num}", I18n.t("validations.household.gender.retired_female") - # record.errors.add "ecstat#{person_num}", I18n.t("validations.household.ecstat.retired_female") - # end - # end - def validate_partner_count(record) partner_count = (2..8).count { |n| tenant_is_partner?(record["relat#{n}"]) } if partner_count > 1 diff --git a/spec/features/form/validations_spec.rb b/spec/features/form/validations_spec.rb index 2965046ef..ad889e241 100644 --- a/spec/features/form/validations_spec.rb +++ b/spec/features/form/validations_spec.rb @@ -131,7 +131,7 @@ RSpec.describe "validations" do click_button("Save and continue") expect(page).to have_current_path("/logs/#{case_log.id}/net-income-value-check") expect(page).to have_content("Net income is outside the expected range based on the lead tenant’s working situation") - expect(page).to have_content("You told us the lead tenant’s working situation is: Full-time – 30 hours or more") + expect(page).to have_content("You told us the lead tenant’s working situation is: full-time – 30 hours or more") expect(page).to have_content("The household income you have entered is £750.00 every week") choose("case-log-net-income-value-check-0-field", allow_label_click: true) click_button("Save and continue") diff --git a/spec/fixtures/exports/case_logs.xml b/spec/fixtures/exports/case_logs.xml index 8a3a15432..ecb5d7736 100644 --- a/spec/fixtures/exports/case_logs.xml +++ b/spec/fixtures/exports/case_logs.xml @@ -165,6 +165,7 @@ {created_by_id} 0 + 1 diff --git a/spec/fixtures/forms/2021_2022.json b/spec/fixtures/forms/2021_2022.json index c2582b6e8..2bf51746c 100644 --- a/spec/fixtures/forms/2021_2022.json +++ b/spec/fixtures/forms/2021_2022.json @@ -600,10 +600,18 @@ }, "net_income_value_check": { "depends_on": [{ "net_income_soft_validation_triggered?": true }], - "title_text": "Net income is outside the expected range based on the lead tenant’s working situation", + "title_text": "soft_validations.net_income.title_text", "informative_text": { "translation": "soft_validations.net_income.hint_text", - "argument": {"ecstat1": "question", "earnings": "question"} + "arguments": [{ + "key": "ecstat1", + "label": true, + "i18n_template": "ecstat1" + }, + {"key": "earnings", + "label": true, + "i18n_template": "earnings" + }] }, "questions": { "net_income_value_check": { @@ -613,10 +621,10 @@ "type": "interruption_screen", "answer_options": { "0": { - "value":"Yes" + "value": "Yes" }, "1": { - "value":"No" + "value": "No" } } } diff --git a/spec/helpers/interruption_screen_helper_spec.rb b/spec/helpers/interruption_screen_helper_spec.rb index 885425dac..026bfeb70 100644 --- a/spec/helpers/interruption_screen_helper_spec.rb +++ b/spec/helpers/interruption_screen_helper_spec.rb @@ -36,7 +36,7 @@ RSpec.describe InterruptionScreenHelper do ], } expect(display_informative_text(informative_text, case_log)) - .to eq("

You told us the lead tenant’s working situation is: Full-time – 30 hours or more.

The household income you have entered is £750.00 every week.

") + .to eq("

You told us the lead tenant’s working situation is: full-time – 30 hours or more.

The household income you have entered is £750.00 every week.

") end end @@ -53,7 +53,7 @@ RSpec.describe InterruptionScreenHelper do ], } expect(display_informative_text(informative_text, case_log)) - .to eq("This is based on the tenant’s work situation: Full-time – 30 hours or more") + .to eq("This is based on the tenant’s work situation: full-time – 30 hours or more") end end @@ -75,7 +75,7 @@ RSpec.describe InterruptionScreenHelper do ], } expect(display_informative_text(informative_text, case_log)) - .to eq("This is based on the tenant’s work situation: Full-time – 30 hours or more") + .to eq("This is based on the tenant’s work situation: full-time – 30 hours or more") end end diff --git a/spec/models/validations/household_validations_spec.rb b/spec/models/validations/household_validations_spec.rb index d4cdf77c3..1028d01a2 100644 --- a/spec/models/validations/household_validations_spec.rb +++ b/spec/models/validations/household_validations_spec.rb @@ -410,16 +410,6 @@ RSpec.describe Validations::HouseholdValidations do end context "when the household contains a person over 70" do - it "validates that person must be retired" do - record.age2 = 71 - record.ecstat2 = 1 - household_validator.validate_household_number_of_other_members(record) - expect(record.errors["ecstat2"]) - .to include(match I18n.t("validations.household.ecstat.retired_over_70", person_num: 2)) - expect(record.errors["age2"]) - .to include(match I18n.t("validations.household.age.retired_over_70", person_num: 2)) - end - it "expects that person under 70 does not need to be retired" do record.age2 = 50 record.ecstat2 = 1 @@ -438,18 +428,6 @@ RSpec.describe Validations::HouseholdValidations do end context "when the household contains a retired male" do - it "validates that person must be over 65" do - record.age2 = 64 - record.sex2 = "M" - record.ecstat2 = 5 - household_validator.validate_household_number_of_other_members(record) - expect(record.errors["age2"]) - .to include(match I18n.t("validations.household.age.retired_male")) - expect(record.errors["sex2"]) - .to include(match I18n.t("validations.household.gender.retired_male")) - expect(record.errors["ecstat2"]) - .to include(match I18n.t("validations.household.ecstat.retired_male")) - end it "expects that person is over 65" do record.age2 = 66 @@ -484,19 +462,6 @@ RSpec.describe Validations::HouseholdValidations do end context "when the household contains a retired female" do - it "validates that person must be over 60" do - record.age2 = 59 - record.sex2 = "F" - record.ecstat2 = 5 - household_validator.validate_household_number_of_other_members(record) - expect(record.errors["age2"]) - .to include(match I18n.t("validations.household.age.retired_female")) - expect(record.errors["sex2"]) - .to include(match I18n.t("validations.household.gender.retired_female")) - expect(record.errors["ecstat2"]) - .to include(match I18n.t("validations.household.ecstat.retired_female")) - end - it "expects that person is over 60" do record.age2 = 61 record.sex2 = "F"