From a58fecb5578d7c9f6fb56e2cd2b74716426076ff Mon Sep 17 00:00:00 2001 From: natdeanlewissoftwire Date: Mon, 16 Jan 2023 09:32:02 +0000 Subject: [PATCH] feat: add depends on behaviour --- app/models/form/sales/pages/mortgage_length.rb | 7 +++++++ spec/models/form/sales/pages/mortgage_length_spec.rb | 4 +++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/app/models/form/sales/pages/mortgage_length.rb b/app/models/form/sales/pages/mortgage_length.rb index 2877cffd8..46ce4d8e0 100644 --- a/app/models/form/sales/pages/mortgage_length.rb +++ b/app/models/form/sales/pages/mortgage_length.rb @@ -1,4 +1,11 @@ class Form::Sales::Pages::MortgageLength < ::Form::Page + def initialize(id, hsh, subsection) + super + @depends_on = [{ + "mortgageused" => 1, + }] + end + def questions @questions ||= [ Form::Sales::Questions::MortgageLength.new(nil, nil, self), diff --git a/spec/models/form/sales/pages/mortgage_length_spec.rb b/spec/models/form/sales/pages/mortgage_length_spec.rb index bc63bc178..ef2573e57 100644 --- a/spec/models/form/sales/pages/mortgage_length_spec.rb +++ b/spec/models/form/sales/pages/mortgage_length_spec.rb @@ -28,6 +28,8 @@ RSpec.describe Form::Sales::Pages::MortgageLength, type: :model do end it "has correct depends_on" do - expect(page.depends_on).to be_nil + expect(page.depends_on).to eq([{ + "mortgageused" => 1, + }]) end end