Browse Source

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
pull/1055/head
kosiakkatrina 2 years ago committed by GitHub
parent
commit
c994e67e69
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      app/models/form/sales/pages/buyer1_income_value_check.rb
  2. 1
      app/models/form/sales/pages/mortgage_value_check.rb
  3. 1
      app/models/form/sales/subsections/household_characteristics.rb
  4. 6
      app/models/form/sales/subsections/income_benefits_and_savings.rb
  5. 4
      spec/models/form/sales/pages/buyer1_income_value_check_spec.rb
  6. 4
      spec/models/form/sales/pages/mortgage_value_check_spec.rb
  7. 1
      spec/models/form/sales/subsections/household_characteristics_spec.rb
  8. 4
      spec/models/form/sales/subsections/income_benefits_and_savings_spec.rb
  9. 4
      spec/models/form_handler_spec.rb

1
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

1
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

1
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),

6
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),
]

4
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

4
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

1
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

4
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
],

4
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

Loading…
Cancel
Save