From c994e67e69459c10abfbea4cc000e5d9ac829e7d Mon Sep 17 00:00:00 2001 From: kosiakkatrina <54268893+kosiakkatrina@users.noreply.github.com> Date: Wed, 14 Dec 2022 10:34:22 +0000 Subject: [PATCH] Use dynamic ids for pages (#1085) * Add income1_value_check column * Use dynamic ids for pages * Display Buyer1IncomeValueCheck twice * Use id argument and pass in full IDs * Remove accidental migration --- app/models/form/sales/pages/buyer1_income_value_check.rb | 1 - app/models/form/sales/pages/mortgage_value_check.rb | 1 - .../form/sales/subsections/household_characteristics.rb | 1 + .../form/sales/subsections/income_benefits_and_savings.rb | 6 ++++-- .../form/sales/pages/buyer1_income_value_check_spec.rb | 4 ++-- spec/models/form/sales/pages/mortgage_value_check_spec.rb | 4 ++-- .../sales/subsections/household_characteristics_spec.rb | 1 + .../sales/subsections/income_benefits_and_savings_spec.rb | 4 +++- spec/models/form_handler_spec.rb | 4 ++-- 9 files changed, 15 insertions(+), 11 deletions(-) diff --git a/app/models/form/sales/pages/buyer1_income_value_check.rb b/app/models/form/sales/pages/buyer1_income_value_check.rb index 243388ed9..51170702e 100644 --- a/app/models/form/sales/pages/buyer1_income_value_check.rb +++ b/app/models/form/sales/pages/buyer1_income_value_check.rb @@ -1,7 +1,6 @@ class Form::Sales::Pages::Buyer1IncomeValueCheck < ::Form::Page def initialize(id, hsh, subsection) super - @id = "buyer_1_income_value_check" @header = "" @description = "" @subsection = subsection diff --git a/app/models/form/sales/pages/mortgage_value_check.rb b/app/models/form/sales/pages/mortgage_value_check.rb index 0495f4f4f..7bbd62cf8 100644 --- a/app/models/form/sales/pages/mortgage_value_check.rb +++ b/app/models/form/sales/pages/mortgage_value_check.rb @@ -1,7 +1,6 @@ class Form::Sales::Pages::MortgageValueCheck < ::Form::Page def initialize(id, hsh, subsection) super - @id = "mortgage_value_check" @header = "" @description = "" @subsection = subsection diff --git a/app/models/form/sales/subsections/household_characteristics.rb b/app/models/form/sales/subsections/household_characteristics.rb index a2232caa2..187d7c108 100644 --- a/app/models/form/sales/subsections/household_characteristics.rb +++ b/app/models/form/sales/subsections/household_characteristics.rb @@ -21,6 +21,7 @@ class Form::Sales::Subsections::HouseholdCharacteristics < ::Form::Subsection Form::Sales::Pages::Buyer1EthnicBackgroundWhite.new(nil, nil, self), Form::Sales::Pages::Nationality1.new(nil, nil, self), Form::Sales::Pages::Buyer1WorkingSituation.new(nil, nil, self), + Form::Sales::Pages::Buyer1IncomeValueCheck.new("working_situation_buyer_1_income_value_check", nil, self), Form::Sales::Pages::Buyer1LiveInProperty.new(nil, nil, self), Form::Sales::Pages::Buyer2RelationshipToBuyer1.new(nil, nil, self), Form::Sales::Pages::Age2.new(nil, nil, self), 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 447aba589..a9bc1a7c9 100644 --- a/app/models/form/sales/subsections/income_benefits_and_savings.rb +++ b/app/models/form/sales/subsections/income_benefits_and_savings.rb @@ -10,10 +10,12 @@ class Form::Sales::Subsections::IncomeBenefitsAndSavings < ::Form::Subsection def pages @pages ||= [ Form::Sales::Pages::Buyer1Income.new(nil, nil, self), - Form::Sales::Pages::Buyer1IncomeValueCheck.new(nil, nil, self), + Form::Sales::Pages::Buyer1IncomeValueCheck.new("buyer_1_income_value_check", nil, self), + Form::Sales::Pages::MortgageValueCheck.new("buyer_1_income_mortgage_value_check", nil, self), Form::Sales::Pages::Buyer1Mortgage.new(nil, nil, self), + Form::Sales::Pages::MortgageValueCheck.new("buyer_1_mortgage_value_check", nil, self), Form::Sales::Pages::Buyer2Income.new(nil, nil, self), - Form::Sales::Pages::MortgageValueCheck.new(nil, nil, self), + Form::Sales::Pages::MortgageValueCheck.new("buyer_2_income_mortgage_value_check", nil, self), Form::Sales::Pages::Savings.new(nil, nil, self), Form::Sales::Pages::PreviousOwnership.new(nil, nil, self), ] diff --git a/spec/models/form/sales/pages/buyer1_income_value_check_spec.rb b/spec/models/form/sales/pages/buyer1_income_value_check_spec.rb index 8cc279d67..18281533e 100644 --- a/spec/models/form/sales/pages/buyer1_income_value_check_spec.rb +++ b/spec/models/form/sales/pages/buyer1_income_value_check_spec.rb @@ -3,7 +3,7 @@ require "rails_helper" RSpec.describe Form::Sales::Pages::Buyer1IncomeValueCheck, type: :model do subject(:page) { described_class.new(page_id, page_definition, subsection) } - let(:page_id) { nil } + let(:page_id) { "prefix_buyer_1_income_value_check" } let(:page_definition) { nil } let(:subsection) { instance_double(Form::Subsection) } @@ -16,7 +16,7 @@ RSpec.describe Form::Sales::Pages::Buyer1IncomeValueCheck, type: :model do end it "has the correct id" do - expect(page.id).to eq("buyer_1_income_value_check") + expect(page.id).to eq("prefix_buyer_1_income_value_check") end it "has the correct header" do diff --git a/spec/models/form/sales/pages/mortgage_value_check_spec.rb b/spec/models/form/sales/pages/mortgage_value_check_spec.rb index 4083df07b..b39daa468 100644 --- a/spec/models/form/sales/pages/mortgage_value_check_spec.rb +++ b/spec/models/form/sales/pages/mortgage_value_check_spec.rb @@ -3,7 +3,7 @@ require "rails_helper" RSpec.describe Form::Sales::Pages::MortgageValueCheck, type: :model do subject(:page) { described_class.new(page_id, page_definition, subsection) } - let(:page_id) { nil } + let(:page_id) { "buyer_1_income_mortgage_value_check" } let(:page_definition) { nil } let(:subsection) { instance_double(Form::Subsection) } @@ -16,7 +16,7 @@ RSpec.describe Form::Sales::Pages::MortgageValueCheck, type: :model do end it "has the correct id" do - expect(page.id).to eq("mortgage_value_check") + expect(page.id).to eq("buyer_1_income_mortgage_value_check") end it "has the correct header" do diff --git a/spec/models/form/sales/subsections/household_characteristics_spec.rb b/spec/models/form/sales/subsections/household_characteristics_spec.rb index 63c27291f..ce464383f 100644 --- a/spec/models/form/sales/subsections/household_characteristics_spec.rb +++ b/spec/models/form/sales/subsections/household_characteristics_spec.rb @@ -26,6 +26,7 @@ RSpec.describe Form::Sales::Subsections::HouseholdCharacteristics, type: :model buyer_1_ethnic_background_white buyer_1_nationality buyer_1_working_situation + working_situation_buyer_1_income_value_check buyer_1_live_in_property buyer_2_relationship_to_buyer_1 buyer_2_age 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 86af4c67a..c7e2c7606 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 @@ -16,9 +16,11 @@ RSpec.describe Form::Sales::Subsections::IncomeBenefitsAndSavings, type: :model %w[ buyer_1_income buyer_1_income_value_check + buyer_1_income_mortgage_value_check buyer_1_mortgage + buyer_1_mortgage_value_check buyer_2_income - mortgage_value_check + buyer_2_income_mortgage_value_check savings previous_ownership ], diff --git a/spec/models/form_handler_spec.rb b/spec/models/form_handler_spec.rb index 0f1cdc5da..7656fe7fb 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(53) + expect(form.pages.count).to eq(56) 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(53) + expect(form.pages.count).to eq(56) expect(form.name).to eq("2021_2022_sales") end end