diff --git a/app/models/form/sales/questions/household_wheelchair_check.rb b/app/models/form/sales/questions/household_wheelchair_check.rb index 1a9db3f3a..0d6cc12bc 100644 --- a/app/models/form/sales/questions/household_wheelchair_check.rb +++ b/app/models/form/sales/questions/household_wheelchair_check.rb @@ -9,15 +9,7 @@ class Form::Sales::Questions::HouseholdWheelchairCheck < ::Form::Question "0" => { "value" => "Yes" }, "1" => { "value" => "No" }, } - @hidden_in_check_answers = { - "depends_on" => [ - { - "wheel_value_check" => 0, - }, - { - "wheel_value_check" => 1, - }, - ], - } + @hidden_in_check_answers = true + @page = page end end diff --git a/app/models/form/sales/subsections/household_needs.rb b/app/models/form/sales/subsections/household_needs.rb index d411d5101..b5d4d528e 100644 --- a/app/models/form/sales/subsections/household_needs.rb +++ b/app/models/form/sales/subsections/household_needs.rb @@ -12,6 +12,7 @@ class Form::Sales::Subsections::HouseholdNeeds < ::Form::Subsection Form::Sales::Pages::BuyerStillServing.new(nil, nil, self), Form::Sales::Pages::ArmedForcesSpouse.new(nil, nil, self), Form::Sales::Pages::HouseholdDisability.new(nil, nil, self), + Form::Sales::Pages::HouseholdWheelchairCheck.new("disability_wheelchair_check", nil, self), Form::Sales::Pages::HouseholdWheelchair.new(nil, nil, self), Form::Sales::Pages::HouseholdWheelchairCheck.new("wheelchair_check", nil, self), ] diff --git a/app/models/validations/sales/soft_validations.rb b/app/models/validations/sales/soft_validations.rb index 3deb92aaa..19c2a13ec 100644 --- a/app/models/validations/sales/soft_validations.rb +++ b/app/models/validations/sales/soft_validations.rb @@ -22,9 +22,9 @@ module Validations::Sales::SoftValidations end def wheelchair_when_not_disabled? - return false unless disabled == 2 + return unless disabled && wheel - wheel == 1 + wheel == 1 && disabled == 2 end def savings_over_soft_max? diff --git a/spec/models/form/sales/questions/household_wheelchair_check_spec.rb b/spec/models/form/sales/questions/household_wheelchair_check_spec.rb index 92f80fdb1..22e5d1ba0 100644 --- a/spec/models/form/sales/questions/household_wheelchair_check_spec.rb +++ b/spec/models/form/sales/questions/household_wheelchair_check_spec.rb @@ -43,6 +43,6 @@ RSpec.describe Form::Sales::Questions::HouseholdWheelchairCheck, type: :model do end it "has the correct hidden_in_check_answers" do - expect(question.hidden_in_check_answers).to eq({ "depends_on" => [{ "wheel_value_check" => 0 }, { "wheel_value_check" => 1 }] }) + expect(question.hidden_in_check_answers).to be true end end diff --git a/spec/models/form/sales/subsections/household_needs_spec.rb b/spec/models/form/sales/subsections/household_needs_spec.rb index 5220f2d05..5395da095 100644 --- a/spec/models/form/sales/subsections/household_needs_spec.rb +++ b/spec/models/form/sales/subsections/household_needs_spec.rb @@ -18,6 +18,7 @@ RSpec.describe Form::Sales::Subsections::HouseholdNeeds, type: :model do buyer_still_serving armed_forces_spouse household_disability + disability_wheelchair_check household_wheelchair wheelchair_check ], diff --git a/spec/models/form_handler_spec.rb b/spec/models/form_handler_spec.rb index c272ac4a9..965e79690 100644 --- a/spec/models/form_handler_spec.rb +++ b/spec/models/form_handler_spec.rb @@ -52,14 +52,14 @@ RSpec.describe FormHandler do it "is able to load a current sales form" do form = form_handler.get_form("current_sales") expect(form).to be_a(Form) - expect(form.pages.count).to eq(182) + expect(form.pages.count).to eq(183) expect(form.name).to eq("2022_2023_sales") end it "is able to load a previous sales form" do form = form_handler.get_form("previous_sales") expect(form).to be_a(Form) - expect(form.pages.count).to eq(182) + expect(form.pages.count).to eq(183) expect(form.name).to eq("2021_2022_sales") end end diff --git a/spec/models/validations/sales/soft_validations_spec.rb b/spec/models/validations/sales/soft_validations_spec.rb index 902790009..34f49d847 100644 --- a/spec/models/validations/sales/soft_validations_spec.rb +++ b/spec/models/validations/sales/soft_validations_spec.rb @@ -7,14 +7,14 @@ RSpec.describe Validations::Sales::SoftValidations do context "when validating soft min" do it "returns false if no income1 is given" do record.income1 = nil - expect(record) - .not_to be_income1_under_soft_min + + expect(record).not_to be_income1_under_soft_min end it "returns false if no ecstat1 is given" do record.ecstat1 = nil - expect(record) - .not_to be_income1_under_soft_min + + expect(record).not_to be_income1_under_soft_min end [ @@ -292,4 +292,41 @@ RSpec.describe Validations::Sales::SoftValidations do expect(record).not_to be_hodate_3_years_or_more_saledate end end + + describe "wheelchair_when_not_disabled" do + it "when hodate not set" do + record.disabled = 2 + record.wheel = nil + + expect(record).not_to be_wheelchair_when_not_disabled + end + + it "when disabled not set" do + record.disabled = nil + record.wheel = 1 + + expect(record).not_to be_wheelchair_when_not_disabled + end + + it "when disabled and wheel not set" do + record.disabled = nil + record.wheel = nil + + expect(record).not_to be_wheelchair_when_not_disabled + end + + it "when disabled == 2 && wheel == 1" do + record.disabled = 2 + record.wheel = 1 + + expect(record).to be_wheelchair_when_not_disabled + end + + it "when disabled == 2 && wheel != 1" do + record.disabled = 2 + record.wheel = 2 + + expect(record).not_to be_wheelchair_when_not_disabled + end + end end