From a6e87c4121cc5800334b2b569193e833be79faaf Mon Sep 17 00:00:00 2001 From: Kat Date: Fri, 2 Dec 2022 08:52:20 +0000 Subject: [PATCH] Add savings page and update subsection --- app/models/form/sales/pages/savings.rb | 16 +++++++++ .../income_benefits_and_savings.rb | 1 + spec/models/form/sales/pages/savings_spec.rb | 33 +++++++++++++++++++ .../income_benefits_and_savings_spec.rb | 1 + 4 files changed, 51 insertions(+) create mode 100644 app/models/form/sales/pages/savings.rb create mode 100644 spec/models/form/sales/pages/savings_spec.rb diff --git a/app/models/form/sales/pages/savings.rb b/app/models/form/sales/pages/savings.rb new file mode 100644 index 000000000..42f2c1bb4 --- /dev/null +++ b/app/models/form/sales/pages/savings.rb @@ -0,0 +1,16 @@ +class Form::Sales::Pages::Savings < ::Form::Page + def initialize(id, hsh, subsection) + super + @id = "savings" + @header = "" + @description = "" + @subsection = subsection + end + + def questions + @questions ||= [ + Form::Sales::Questions::SavingsNk.new(nil, nil, self), + Form::Sales::Questions::Savings.new(nil, nil, self), + ] + end +end diff --git a/app/models/form/sales/subsections/income_benefits_and_savings.rb b/app/models/form/sales/subsections/income_benefits_and_savings.rb index 26ab3310b..aed3304ba 100644 --- a/app/models/form/sales/subsections/income_benefits_and_savings.rb +++ b/app/models/form/sales/subsections/income_benefits_and_savings.rb @@ -12,6 +12,7 @@ class Form::Sales::Subsections::IncomeBenefitsAndSavings < ::Form::Subsection Form::Sales::Pages::Buyer1Income.new(nil, nil, self), Form::Sales::Pages::Buyer1Mortgage.new(nil, nil, self), Form::Sales::Pages::Buyer2Income.new(nil, nil, self), + Form::Sales::Pages::Savings.new(nil, nil, self), ] end end diff --git a/spec/models/form/sales/pages/savings_spec.rb b/spec/models/form/sales/pages/savings_spec.rb new file mode 100644 index 000000000..37093da26 --- /dev/null +++ b/spec/models/form/sales/pages/savings_spec.rb @@ -0,0 +1,33 @@ +require "rails_helper" + +RSpec.describe Form::Sales::Pages::Savings, type: :model do + subject(:page) { described_class.new(page_id, page_definition, subsection) } + + let(:page_id) { nil } + let(:page_definition) { nil } + let(:subsection) { instance_double(Form::Subsection) } + + it "has correct subsection" do + expect(page.subsection).to eq(subsection) + end + + it "has correct questions" do + expect(page.questions.map(&:id)).to eq(%w[savingsnk savings]) + end + + it "has the correct id" do + expect(page.id).to eq("savings") + end + + it "has the correct header" do + expect(page.header).to eq("") + end + + it "has the correct description" do + expect(page.description).to eq("") + end + + it "has correct depends_on" do + expect(page.depends_on).to be_nil + end +end diff --git a/spec/models/form/sales/subsections/income_benefits_and_savings_spec.rb b/spec/models/form/sales/subsections/income_benefits_and_savings_spec.rb index bea0fe88d..95735c020 100644 --- a/spec/models/form/sales/subsections/income_benefits_and_savings_spec.rb +++ b/spec/models/form/sales/subsections/income_benefits_and_savings_spec.rb @@ -17,6 +17,7 @@ RSpec.describe Form::Sales::Subsections::IncomeBenefitsAndSavings, type: :model buyer_1_income buyer_1_mortgage buyer_2_income + savings ], ) end