Browse Source

CLDC-2010 Add discounted ownership max income soft validations (#1518)

* feat: add max value check for buyer 1

* feat: add tests and refactor

* feat: add buyer 2 value check

* feat: combined income value check

* feat: add combined validation everywhere and add tests

* feat: add max value check for buyer 1

* feat: add tests and refactor

* feat: add buyer 2 value check

* feat: combined income value check

* feat: add combined validation everywhere and add tests

* db:update

* refactor: lint

* db: update

* feat: update copy for single validations

* feat: add correct answer card numbers

* feat: add tests

* feat: fix tests

* feat: correct uprn address routing not to show when uprn_confirmed is nil

* refactor: lint

* feat: update tests

* feat: make combined_income nil safe

* feat: merge with main

* test: update

* feat: update to new soft val designs

* feat: replace la with uprn, postoce_full, la in all interruption_screen_question_ids

* feat: update tests
pull/1630/head
natdeanlewissoftwire 2 years ago committed by GitHub
parent
commit
dd1f65776d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      app/models/form/lettings/pages/max_rent_value_check.rb
  2. 2
      app/models/form/lettings/pages/min_rent_value_check.rb
  3. 2
      app/models/form/sales/pages/about_price_value_check.rb
  4. 2
      app/models/form/sales/pages/address.rb
  5. 32
      app/models/form/sales/pages/buyer1_income_max_value_check.rb
  6. 4
      app/models/form/sales/pages/buyer1_income_min_value_check.rb
  7. 32
      app/models/form/sales/pages/buyer2_income_max_value_check.rb
  8. 7
      app/models/form/sales/pages/buyer2_income_min_value_check.rb
  9. 32
      app/models/form/sales/pages/combined_income_max_value_check.rb
  10. 9
      app/models/form/sales/questions/buyer1_income_value_check.rb
  11. 8
      app/models/form/sales/questions/buyer2_income_value_check.rb
  12. 25
      app/models/form/sales/questions/combined_income_value_check.rb
  13. 4
      app/models/form/sales/subsections/household_characteristics.rb
  14. 8
      app/models/form/sales/subsections/income_benefits_and_savings.rb
  15. 6
      app/models/form/sales/subsections/property_information.rb
  16. 7
      app/models/sales_log.rb
  17. 22
      app/models/validations/sales/soft_validations.rb
  18. 3
      config/locales/en.yml
  19. 5
      db/migrate/20230405132300_add_combined_income_value_check_to_sales_log.rb
  20. 1
      db/schema.rb
  21. 2
      spec/models/form/lettings/pages/max_rent_value_check_spec.rb
  22. 2
      spec/models/form/lettings/pages/min_rent_value_check_spec.rb
  23. 2
      spec/models/form/sales/pages/about_price_value_check_spec.rb
  24. 37
      spec/models/form/sales/pages/buyer1_income_max_value_check_spec.rb
  25. 6
      spec/models/form/sales/pages/buyer1_income_min_value_check_spec.rb
  26. 37
      spec/models/form/sales/pages/buyer2_income_max_value_check_spec.rb
  27. 37
      spec/models/form/sales/pages/buyer2_income_min_value_check_spec.rb
  28. 37
      spec/models/form/sales/pages/combined_income_max_value_check_spec.rb
  29. 4
      spec/models/form/sales/questions/buyer1_income_value_check_spec.rb
  30. 61
      spec/models/form/sales/questions/buyer2_income_value_check_spec.rb
  31. 61
      spec/models/form/sales/questions/combined_income_value_check_spec.rb
  32. 8
      spec/models/form/sales/subsections/household_characteristics_spec.rb
  33. 16
      spec/models/form/sales/subsections/income_benefits_and_savings_spec.rb
  34. 6
      spec/models/form/sales/subsections/property_information_spec.rb

2
app/models/form/lettings/pages/max_rent_value_check.rb

@ -30,6 +30,6 @@ class Form::Lettings::Pages::MaxRentValueCheck < ::Form::Page
end end
def interruption_screen_question_ids def interruption_screen_question_ids
%w[brent startdate la beds rent_type needstype] %w[brent startdate uprn postcode_full la beds rent_type needstype]
end end
end end

2
app/models/form/lettings/pages/min_rent_value_check.rb

@ -26,6 +26,6 @@ class Form::Lettings::Pages::MinRentValueCheck < ::Form::Page
end end
def interruption_screen_question_ids def interruption_screen_question_ids
%w[brent startdate la beds rent_type needstype] %w[brent startdate uprn postcode_full la beds rent_type needstype]
end end
end end

2
app/models/form/sales/pages/about_price_value_check.rb

@ -39,6 +39,6 @@ class Form::Sales::Pages::AboutPriceValueCheck < ::Form::Page
end end
def interruption_screen_question_ids def interruption_screen_question_ids
%w[value beds la] %w[value beds uprn postcode_full la]
end end
end end

2
app/models/form/sales/pages/address.rb

@ -18,6 +18,6 @@ class Form::Sales::Pages::Address < ::Form::Page
def routed_to?(log, _current_user = nil) def routed_to?(log, _current_user = nil)
return false if log.uprn_known.nil? return false if log.uprn_known.nil?
log.uprn_confirmed != 1 || log.uprn_known.zero? log.uprn_known.zero? || log.uprn_confirmed&.zero?
end end
end end

32
app/models/form/sales/pages/buyer1_income_max_value_check.rb

@ -0,0 +1,32 @@
class Form::Sales::Pages::Buyer1IncomeMaxValueCheck < ::Form::Page
def initialize(id, hsh, subsection, check_answers_card_number:)
super(id, hsh, subsection)
@depends_on = [
{
"income1_over_soft_max?" => true,
},
]
@title_text = {
"translation" => "soft_validations.income.over_soft_max_for_la_buyer_1",
"arguments" => [
{
"key" => "field_formatted_as_currency",
"arguments_for_key" => "income1",
"i18n_template" => "income",
},
],
}
@informative_text = {}
@check_answers_card_number = check_answers_card_number
end
def questions
@questions ||= [
Form::Sales::Questions::Buyer1IncomeValueCheck.new(nil, nil, self, check_answers_card_number: @check_answers_card_number),
]
end
def interruption_screen_question_ids
%w[uprn postcode_full la income1]
end
end

4
app/models/form/sales/pages/buyer1_income_value_check.rb → app/models/form/sales/pages/buyer1_income_min_value_check.rb

@ -1,4 +1,4 @@
class Form::Sales::Pages::Buyer1IncomeValueCheck < ::Form::Page class Form::Sales::Pages::Buyer1IncomeMinValueCheck < ::Form::Page
def initialize(id, hsh, subsection) def initialize(id, hsh, subsection)
super super
@depends_on = [ @depends_on = [
@ -29,7 +29,7 @@ class Form::Sales::Pages::Buyer1IncomeValueCheck < ::Form::Page
def questions def questions
@questions ||= [ @questions ||= [
Form::Sales::Questions::Buyer1IncomeValueCheck.new(nil, nil, self), Form::Sales::Questions::Buyer1IncomeValueCheck.new(nil, nil, self, check_answers_card_number: 1),
] ]
end end

32
app/models/form/sales/pages/buyer2_income_max_value_check.rb

@ -0,0 +1,32 @@
class Form::Sales::Pages::Buyer2IncomeMaxValueCheck < ::Form::Page
def initialize(id, hsh, subsection, check_answers_card_number:)
super(id, hsh, subsection)
@depends_on = [
{
"income2_over_soft_max?" => true,
},
]
@title_text = {
"translation" => "soft_validations.income.over_soft_max_for_la_buyer_2",
"arguments" => [
{
"key" => "field_formatted_as_currency",
"arguments_for_key" => "income2",
"i18n_template" => "income",
},
],
}
@informative_text = {}
@check_answers_card_number = check_answers_card_number
end
def questions
@questions ||= [
Form::Sales::Questions::Buyer2IncomeValueCheck.new(nil, nil, self, check_answers_card_number: @check_answers_card_number),
]
end
def interruption_screen_question_ids
%w[uprn postcode_full la income2]
end
end

7
app/models/form/sales/pages/buyer2_income_value_check.rb → app/models/form/sales/pages/buyer2_income_min_value_check.rb

@ -1,9 +1,6 @@
class Form::Sales::Pages::Buyer2IncomeValueCheck < ::Form::Page class Form::Sales::Pages::Buyer2IncomeMinValueCheck < ::Form::Page
def initialize(id, hsh, subsection) def initialize(id, hsh, subsection)
super super
@header = ""
@description = ""
@subsection = subsection
@depends_on = [ @depends_on = [
{ {
"income2_under_soft_min?" => true, "income2_under_soft_min?" => true,
@ -32,7 +29,7 @@ class Form::Sales::Pages::Buyer2IncomeValueCheck < ::Form::Page
def questions def questions
@questions ||= [ @questions ||= [
Form::Sales::Questions::Buyer2IncomeValueCheck.new(nil, nil, self), Form::Sales::Questions::Buyer2IncomeValueCheck.new(nil, nil, self, check_answers_card_number: 2),
] ]
end end

32
app/models/form/sales/pages/combined_income_max_value_check.rb

@ -0,0 +1,32 @@
class Form::Sales::Pages::CombinedIncomeMaxValueCheck < ::Form::Page
def initialize(id, hsh, subsection, check_answers_card_number:)
super(id, hsh, subsection)
@depends_on = [
{
"combined_income_over_soft_max?" => true,
},
]
@title_text = {
"translation" => "soft_validations.income.over_soft_max_for_la_combined",
"arguments" => [
{
"key" => "field_formatted_as_currency",
"arguments_for_key" => "combined_income",
"i18n_template" => "combined_income",
},
],
}
@informative_text = {}
@check_answers_card_number = check_answers_card_number
end
def questions
@questions ||= [
Form::Sales::Questions::CombinedIncomeValueCheck.new(nil, nil, self, check_answers_card_number: @check_answers_card_number),
]
end
def interruption_screen_question_ids
%w[uprn postcode_full la income1 income2]
end
end

9
app/models/form/sales/questions/buyer1_income_value_check.rb

@ -1,8 +1,8 @@
class Form::Sales::Questions::Buyer1IncomeValueCheck < ::Form::Question class Form::Sales::Questions::Buyer1IncomeValueCheck < ::Form::Question
def initialize(id, hsh, page) def initialize(id, hsh, page, check_answers_card_number:)
super super(id, hsh, page)
@id = "income1_value_check" @id = "income1_value_check"
@check_answer_label = "Income confirmation" @check_answer_label = "Buyer 1 income confirmation"
@header = "Are you sure this is correct?" @header = "Are you sure this is correct?"
@type = "interruption_screen" @type = "interruption_screen"
@answer_options = { @answer_options = {
@ -19,6 +19,7 @@ class Form::Sales::Questions::Buyer1IncomeValueCheck < ::Form::Question
}, },
], ],
} }
@check_answers_card_number = 1 @check_answers_card_number = check_answers_card_number
@page = page
end end
end end

8
app/models/form/sales/questions/buyer2_income_value_check.rb

@ -1,8 +1,8 @@
class Form::Sales::Questions::Buyer2IncomeValueCheck < ::Form::Question class Form::Sales::Questions::Buyer2IncomeValueCheck < ::Form::Question
def initialize(id, hsh, page) def initialize(id, hsh, page, check_answers_card_number:)
super super(id, hsh, page)
@id = "income2_value_check" @id = "income2_value_check"
@check_answer_label = "Income confirmation" @check_answer_label = "Buyer 2 income confirmation"
@header = "Are you sure this is correct?" @header = "Are you sure this is correct?"
@type = "interruption_screen" @type = "interruption_screen"
@answer_options = { @answer_options = {
@ -19,7 +19,7 @@ class Form::Sales::Questions::Buyer2IncomeValueCheck < ::Form::Question
}, },
], ],
} }
@check_answers_card_number = 2 @check_answers_card_number = check_answers_card_number
@page = page @page = page
end end
end end

25
app/models/form/sales/questions/combined_income_value_check.rb

@ -0,0 +1,25 @@
class Form::Sales::Questions::CombinedIncomeValueCheck < ::Form::Question
def initialize(id, hsh, page, check_answers_card_number:)
super(id, hsh, page)
@id = "combined_income_value_check"
@check_answer_label = "Combined income confirmation"
@header = "Are you sure this is correct?"
@type = "interruption_screen"
@answer_options = {
"0" => { "value" => "Yes" },
"1" => { "value" => "No" },
}
@hidden_in_check_answers = {
"depends_on" => [
{
"combined_income_value_check" => 0,
},
{
"combined_income_value_check" => 1,
},
],
}
@check_answers_card_number = check_answers_card_number
@page = page
end
end

4
app/models/form/sales/subsections/household_characteristics.rb

@ -24,7 +24,7 @@ class Form::Sales::Subsections::HouseholdCharacteristics < ::Form::Subsection
Form::Sales::Pages::Nationality1.new(nil, nil, self), Form::Sales::Pages::Nationality1.new(nil, nil, self),
Form::Sales::Pages::Buyer1WorkingSituation.new(nil, nil, self), Form::Sales::Pages::Buyer1WorkingSituation.new(nil, nil, self),
Form::Sales::Pages::RetirementValueCheck.new("working_situation_1_retirement_value_check", nil, self, person_index: 1), Form::Sales::Pages::RetirementValueCheck.new("working_situation_1_retirement_value_check", nil, self, person_index: 1),
Form::Sales::Pages::Buyer1IncomeValueCheck.new("working_situation_buyer_1_income_value_check", nil, self), Form::Sales::Pages::Buyer1IncomeMinValueCheck.new("working_situation_buyer_1_income_min_value_check", nil, self),
Form::Sales::Pages::Buyer1LiveInProperty.new(nil, nil, self), Form::Sales::Pages::Buyer1LiveInProperty.new(nil, nil, self),
Form::Sales::Pages::BuyerLiveInValueCheck.new("buyer_1_live_in_property_value_check", nil, self, person_index: 1), Form::Sales::Pages::BuyerLiveInValueCheck.new("buyer_1_live_in_property_value_check", nil, self, person_index: 1),
Form::Sales::Pages::Buyer2RelationshipToBuyer1.new(nil, nil, self), Form::Sales::Pages::Buyer2RelationshipToBuyer1.new(nil, nil, self),
@ -38,7 +38,7 @@ class Form::Sales::Subsections::HouseholdCharacteristics < ::Form::Subsection
buyer_2_ethnicity_nationality_pages, buyer_2_ethnicity_nationality_pages,
Form::Sales::Pages::Buyer2WorkingSituation.new(nil, nil, self), Form::Sales::Pages::Buyer2WorkingSituation.new(nil, nil, self),
Form::Sales::Pages::RetirementValueCheck.new("working_situation_2_retirement_value_check_joint_purchase", nil, self, person_index: 2), Form::Sales::Pages::RetirementValueCheck.new("working_situation_2_retirement_value_check_joint_purchase", nil, self, person_index: 2),
Form::Sales::Pages::Buyer2IncomeValueCheck.new("working_situation_buyer_2_income_value_check", nil, self), Form::Sales::Pages::Buyer2IncomeMinValueCheck.new("working_situation_buyer_2_income_min_value_check", nil, self),
Form::Sales::Pages::PersonStudentNotChildValueCheck.new("buyer_2_working_situation_student_not_child_value_check", nil, self, person_index: 2), Form::Sales::Pages::PersonStudentNotChildValueCheck.new("buyer_2_working_situation_student_not_child_value_check", nil, self, person_index: 2),
Form::Sales::Pages::Buyer2LiveInProperty.new(nil, nil, self), Form::Sales::Pages::Buyer2LiveInProperty.new(nil, nil, self),
Form::Sales::Pages::BuyerLiveInValueCheck.new("buyer_2_live_in_property_value_check", nil, self, person_index: 2), Form::Sales::Pages::BuyerLiveInValueCheck.new("buyer_2_live_in_property_value_check", nil, self, person_index: 2),

8
app/models/form/sales/subsections/income_benefits_and_savings.rb

@ -9,13 +9,17 @@ class Form::Sales::Subsections::IncomeBenefitsAndSavings < ::Form::Subsection
def pages def pages
@pages ||= [ @pages ||= [
Form::Sales::Pages::Buyer1Income.new(nil, nil, self), Form::Sales::Pages::Buyer1Income.new(nil, nil, self),
Form::Sales::Pages::Buyer1IncomeValueCheck.new("buyer_1_income_value_check", nil, self), Form::Sales::Pages::Buyer1IncomeMinValueCheck.new("buyer_1_income_min_value_check", nil, self),
Form::Sales::Pages::Buyer1IncomeMaxValueCheck.new("buyer_1_income_max_value_check", nil, self, check_answers_card_number: 1),
Form::Sales::Pages::CombinedIncomeMaxValueCheck.new("buyer_1_combined_income_max_value_check", nil, self, check_answers_card_number: 1),
Form::Sales::Pages::MortgageValueCheck.new("buyer_1_income_mortgage_value_check", nil, self, 1), Form::Sales::Pages::MortgageValueCheck.new("buyer_1_income_mortgage_value_check", nil, self, 1),
Form::Sales::Pages::Buyer1Mortgage.new(nil, nil, self), Form::Sales::Pages::Buyer1Mortgage.new(nil, nil, self),
Form::Sales::Pages::MortgageValueCheck.new("buyer_1_mortgage_value_check", nil, self, 1), Form::Sales::Pages::MortgageValueCheck.new("buyer_1_mortgage_value_check", nil, self, 1),
Form::Sales::Pages::Buyer2Income.new(nil, nil, self), Form::Sales::Pages::Buyer2Income.new(nil, nil, self),
Form::Sales::Pages::MortgageValueCheck.new("buyer_2_income_mortgage_value_check", nil, self, 2), Form::Sales::Pages::MortgageValueCheck.new("buyer_2_income_mortgage_value_check", nil, self, 2),
Form::Sales::Pages::Buyer2IncomeValueCheck.new("buyer_2_income_value_check", nil, self), Form::Sales::Pages::Buyer2IncomeMinValueCheck.new("buyer_2_income_min_value_check", nil, self),
Form::Sales::Pages::Buyer2IncomeMaxValueCheck.new("buyer_2_income_max_value_check", nil, self, check_answers_card_number: 2),
Form::Sales::Pages::CombinedIncomeMaxValueCheck.new("buyer_2_combined_income_max_value_check", nil, self, check_answers_card_number: 2),
Form::Sales::Pages::Buyer2Mortgage.new(nil, nil, self), Form::Sales::Pages::Buyer2Mortgage.new(nil, nil, self),
Form::Sales::Pages::MortgageValueCheck.new("buyer_2_mortgage_value_check", nil, self, 2), Form::Sales::Pages::MortgageValueCheck.new("buyer_2_mortgage_value_check", nil, self, 2),
Form::Sales::Pages::HousingBenefits.new("housing_benefits_joint_purchase", nil, self, joint_purchase: true), Form::Sales::Pages::HousingBenefits.new("housing_benefits_joint_purchase", nil, self, joint_purchase: true),

6
app/models/form/sales/subsections/property_information.rb

@ -28,6 +28,9 @@ class Form::Sales::Subsections::PropertyInformation < ::Form::Subsection
Form::Sales::Pages::UprnConfirmation.new(nil, nil, self), Form::Sales::Pages::UprnConfirmation.new(nil, nil, self),
Form::Sales::Pages::Address.new(nil, nil, self), Form::Sales::Pages::Address.new(nil, nil, self),
Form::Sales::Pages::PropertyLocalAuthority.new(nil, nil, self), Form::Sales::Pages::PropertyLocalAuthority.new(nil, nil, self),
Form::Sales::Pages::Buyer1IncomeMaxValueCheck.new("local_authority_buyer_1_income_max_value_check", nil, self, check_answers_card_number: nil),
Form::Sales::Pages::Buyer2IncomeMaxValueCheck.new("local_authority_buyer_2_income_max_value_check", nil, self, check_answers_card_number: nil),
Form::Sales::Pages::CombinedIncomeMaxValueCheck.new("local_authority_combined_income_max_value_check", nil, self, check_answers_card_number: nil),
] ]
end end
end end
@ -37,6 +40,9 @@ class Form::Sales::Subsections::PropertyInformation < ::Form::Subsection
[ [
Form::Sales::Pages::Postcode.new(nil, nil, self), Form::Sales::Pages::Postcode.new(nil, nil, self),
Form::Sales::Pages::PropertyLocalAuthority.new(nil, nil, self), Form::Sales::Pages::PropertyLocalAuthority.new(nil, nil, self),
Form::Sales::Pages::Buyer1IncomeMaxValueCheck.new("local_authority_buyer_1_income_max_value_check", nil, self, check_answers_card_number: nil),
Form::Sales::Pages::Buyer2IncomeMaxValueCheck.new("local_authority_buyer_2_income_max_value_check", nil, self, check_answers_card_number: nil),
Form::Sales::Pages::CombinedIncomeMaxValueCheck.new("local_authority_combined_income_max_value_check", nil, self, check_answers_card_number: nil),
] ]
end end
end end

7
app/models/sales_log.rb

@ -386,6 +386,13 @@ class SalesLog < Log
end end
end end
def combined_income
buyer_1_income = income1 || 0
buyer_2_income = income2 || 0
buyer_1_income + buyer_2_income
end
def blank_compound_invalid_non_setup_fields! def blank_compound_invalid_non_setup_fields!
super super

22
app/models/validations/sales/soft_validations.rb

@ -19,6 +19,24 @@ module Validations::Sales::SoftValidations
income2 < ALLOWED_INCOME_RANGES_SALES[ecstat2][:soft_min] income2 < ALLOWED_INCOME_RANGES_SALES[ecstat2][:soft_min]
end end
def income1_over_soft_max?
return unless income1 && la && discounted_ownership_sale?
income_over_soft_max?(income1)
end
def income2_over_soft_max?
return unless income2 && la && discounted_ownership_sale?
income_over_soft_max?(income2)
end
def combined_income_over_soft_max?
return unless income1 && income2 && la && discounted_ownership_sale?
income_over_soft_max?(income1 + income2)
end
def staircase_bought_above_fifty? def staircase_bought_above_fifty?
stairbought && stairbought > 50 stairbought && stairbought > 50
end end
@ -156,4 +174,8 @@ private
bedrooms: beds_for_la_sale_range, bedrooms: beds_for_la_sale_range,
) )
end end
def income_over_soft_max?(income)
(london_property? && income > 90_000) || (property_not_in_london? && income > 80_000)
end
end end

3
config/locales/en.yml

@ -544,6 +544,9 @@ en:
under_soft_min_for_economic_status: under_soft_min_for_economic_status:
title_text: "You told us income was %{income}." title_text: "You told us income was %{income}."
hint_text: "This is less than we would expect for someone in this working situation." hint_text: "This is less than we would expect for someone in this working situation."
over_soft_max_for_la_buyer_1: "You told us the income of buyer 1 is %{income}. This seems high. Are you sure this is correct?"
over_soft_max_for_la_buyer_2: "You told us the income of buyer 2 is %{income}. This seems high. Are you sure this is correct?"
over_soft_max_for_la_combined: "You told us the combined income of this household is %{combined_income}. This seems high. Are you sure this is correct?"
rent: rent:
outside_range_title: "You told us the rent is %{brent}" outside_range_title: "You told us the rent is %{brent}"
min_hint_text: "The minimum rent expected for this type of property in this local authority is %{soft_min_for_period}." min_hint_text: "The minimum rent expected for this type of property in this local authority is %{soft_min_for_period}."

5
db/migrate/20230405132300_add_combined_income_value_check_to_sales_log.rb

@ -0,0 +1,5 @@
class AddCombinedIncomeValueCheckToSalesLog < ActiveRecord::Migration[7.0]
def change
add_column :sales_logs, :combined_income_value_check, :integer
end
end

1
db/schema.rb

@ -599,6 +599,7 @@ ActiveRecord::Schema[7.0].define(version: 2023_05_05_105327) do
t.integer "student_not_child_value_check" t.integer "student_not_child_value_check"
t.integer "percentage_discount_value_check" t.integer "percentage_discount_value_check"
t.integer "buyer_livein_value_check" t.integer "buyer_livein_value_check"
t.integer "combined_income_value_check"
t.integer "status_cache", default: 0, null: false t.integer "status_cache", default: 0, null: false
t.index ["bulk_upload_id"], name: "index_sales_logs_on_bulk_upload_id" t.index ["bulk_upload_id"], name: "index_sales_logs_on_bulk_upload_id"
t.index ["created_by_id"], name: "index_sales_logs_on_created_by_id" t.index ["created_by_id"], name: "index_sales_logs_on_created_by_id"

2
spec/models/form/lettings/pages/max_rent_value_check_spec.rb

@ -36,6 +36,6 @@ RSpec.describe Form::Lettings::Pages::MaxRentValueCheck, type: :model do
end end
it "has the correct interruption_screen_question_ids" do it "has the correct interruption_screen_question_ids" do
expect(page.interruption_screen_question_ids).to eq(%w[brent startdate la beds rent_type needstype]) expect(page.interruption_screen_question_ids).to eq(%w[brent startdate uprn postcode_full la beds rent_type needstype])
end end
end end

2
spec/models/form/lettings/pages/min_rent_value_check_spec.rb

@ -54,6 +54,6 @@ RSpec.describe Form::Lettings::Pages::MinRentValueCheck, type: :model do
end end
it "has the correct interruption_screen_question_ids" do it "has the correct interruption_screen_question_ids" do
expect(page.interruption_screen_question_ids).to eq(%w[brent startdate la beds rent_type needstype]) expect(page.interruption_screen_question_ids).to eq(%w[brent startdate uprn postcode_full la beds rent_type needstype])
end end
end end

2
spec/models/form/sales/pages/about_price_value_check_spec.rb

@ -53,6 +53,6 @@ RSpec.describe Form::Sales::Pages::AboutPriceValueCheck, type: :model do
end end
it "has the correct interruption_screen_question_ids" do it "has the correct interruption_screen_question_ids" do
expect(page.interruption_screen_question_ids).to eq(%w[value beds la]) expect(page.interruption_screen_question_ids).to eq(%w[value beds uprn postcode_full la])
end end
end end

37
spec/models/form/sales/pages/buyer1_income_max_value_check_spec.rb

@ -0,0 +1,37 @@
require "rails_helper"
RSpec.describe Form::Sales::Pages::Buyer1IncomeMaxValueCheck, type: :model do
subject(:page) { described_class.new(page_id, page_definition, subsection, check_answers_card_number: 1) }
let(:page_id) { "prefix_buyer_1_income_max_value_check" }
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[income1_value_check])
end
it "has the correct id" do
expect(page.id).to eq("prefix_buyer_1_income_max_value_check")
end
it "has the correct header" do
expect(page.header).to be_nil
end
it "has correct depends_on" do
expect(page.depends_on).to eq([
{
"income1_over_soft_max?" => true,
},
])
end
it "is interruption screen page" do
expect(page.interruption_screen?).to eq(true)
end
end

6
spec/models/form/sales/pages/buyer1_income_value_check_spec.rb → spec/models/form/sales/pages/buyer1_income_min_value_check_spec.rb

@ -1,9 +1,9 @@
require "rails_helper" require "rails_helper"
RSpec.describe Form::Sales::Pages::Buyer1IncomeValueCheck, type: :model do RSpec.describe Form::Sales::Pages::Buyer1IncomeMinValueCheck, type: :model do
subject(:page) { described_class.new(page_id, page_definition, subsection) } subject(:page) { described_class.new(page_id, page_definition, subsection) }
let(:page_id) { "prefix_buyer_1_income_value_check" } let(:page_id) { "prefix_buyer_1_income_min_value_check" }
let(:page_definition) { nil } let(:page_definition) { nil }
let(:subsection) { instance_double(Form::Subsection) } let(:subsection) { instance_double(Form::Subsection) }
@ -16,7 +16,7 @@ RSpec.describe Form::Sales::Pages::Buyer1IncomeValueCheck, type: :model do
end end
it "has the correct id" do it "has the correct id" do
expect(page.id).to eq("prefix_buyer_1_income_value_check") expect(page.id).to eq("prefix_buyer_1_income_min_value_check")
end end
it "has the correct header" do it "has the correct header" do

37
spec/models/form/sales/pages/buyer2_income_max_value_check_spec.rb

@ -0,0 +1,37 @@
require "rails_helper"
RSpec.describe Form::Sales::Pages::Buyer2IncomeMaxValueCheck, type: :model do
subject(:page) { described_class.new(page_id, page_definition, subsection, check_answers_card_number: 2) }
let(:page_id) { "prefix_buyer_2_income_max_value_check" }
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[income2_value_check])
end
it "has the correct id" do
expect(page.id).to eq("prefix_buyer_2_income_max_value_check")
end
it "has the correct header" do
expect(page.header).to be_nil
end
it "has correct depends_on" do
expect(page.depends_on).to eq([
{
"income2_over_soft_max?" => true,
},
])
end
it "is interruption screen page" do
expect(page.interruption_screen?).to eq(true)
end
end

37
spec/models/form/sales/pages/buyer2_income_min_value_check_spec.rb

@ -0,0 +1,37 @@
require "rails_helper"
RSpec.describe Form::Sales::Pages::Buyer2IncomeMinValueCheck, type: :model do
subject(:page) { described_class.new(page_id, page_definition, subsection) }
let(:page_id) { "prefix_buyer_2_income_min_value_check" }
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[income2_value_check])
end
it "has the correct id" do
expect(page.id).to eq("prefix_buyer_2_income_min_value_check")
end
it "has the correct header" do
expect(page.header).to be_nil
end
it "has correct depends_on" do
expect(page.depends_on).to eq([
{
"income2_under_soft_min?" => true,
},
])
end
it "is interruption screen page" do
expect(page.interruption_screen?).to eq(true)
end
end

37
spec/models/form/sales/pages/combined_income_max_value_check_spec.rb

@ -0,0 +1,37 @@
require "rails_helper"
RSpec.describe Form::Sales::Pages::CombinedIncomeMaxValueCheck, type: :model do
subject(:page) { described_class.new(page_id, page_definition, subsection, check_answers_card_number: nil) }
let(:page_id) { "prefix_combined_income_max_value_check" }
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[combined_income_value_check])
end
it "has the correct id" do
expect(page.id).to eq("prefix_combined_income_max_value_check")
end
it "has the correct header" do
expect(page.header).to be_nil
end
it "has correct depends_on" do
expect(page.depends_on).to eq([
{
"combined_income_over_soft_max?" => true,
},
])
end
it "is interruption screen page" do
expect(page.interruption_screen?).to eq(true)
end
end

4
spec/models/form/sales/questions/buyer1_income_value_check_spec.rb

@ -1,7 +1,7 @@
require "rails_helper" require "rails_helper"
RSpec.describe Form::Sales::Questions::Buyer1IncomeValueCheck, type: :model do RSpec.describe Form::Sales::Questions::Buyer1IncomeValueCheck, type: :model do
subject(:question) { described_class.new(question_id, question_definition, page) } subject(:question) { described_class.new(question_id, question_definition, page, check_answers_card_number: 1) }
let(:question_id) { nil } let(:question_id) { nil }
let(:question_definition) { nil } let(:question_definition) { nil }
@ -20,7 +20,7 @@ RSpec.describe Form::Sales::Questions::Buyer1IncomeValueCheck, type: :model do
end end
it "has the correct check_answer_label" do it "has the correct check_answer_label" do
expect(question.check_answer_label).to eq("Income confirmation") expect(question.check_answer_label).to eq("Buyer 1 income confirmation")
end end
it "has the correct type" do it "has the correct type" do

61
spec/models/form/sales/questions/buyer2_income_value_check_spec.rb

@ -0,0 +1,61 @@
require "rails_helper"
RSpec.describe Form::Sales::Questions::Buyer2IncomeValueCheck, type: :model do
subject(:question) { described_class.new(question_id, question_definition, page, check_answers_card_number: 2) }
let(:question_id) { nil }
let(:question_definition) { nil }
let(:page) { instance_double(Form::Page) }
it "has correct page" do
expect(question.page).to eq(page)
end
it "has the correct id" do
expect(question.id).to eq("income2_value_check")
end
it "has the correct header" do
expect(question.header).to eq("Are you sure this is correct?")
end
it "has the correct check_answer_label" do
expect(question.check_answer_label).to eq("Buyer 2 income confirmation")
end
it "has the correct type" do
expect(question.type).to eq("interruption_screen")
end
it "is not marked as derived" do
expect(question.derived?).to be false
end
it "has the correct hint" do
expect(question.hint_text).to be_nil
end
it "has a correct check_answers_card_number" do
expect(question.check_answers_card_number).to eq(2)
end
it "has the correct answer_options" do
expect(question.answer_options).to eq({
"0" => { "value" => "Yes" },
"1" => { "value" => "No" },
})
end
it "has the correct hidden_in_check_answers" do
expect(question.hidden_in_check_answers).to eq({
"depends_on" => [
{
"income2_value_check" => 0,
},
{
"income2_value_check" => 1,
},
],
})
end
end

61
spec/models/form/sales/questions/combined_income_value_check_spec.rb

@ -0,0 +1,61 @@
require "rails_helper"
RSpec.describe Form::Sales::Questions::CombinedIncomeValueCheck, type: :model do
subject(:question) { described_class.new(question_id, question_definition, page, check_answers_card_number: nil) }
let(:question_id) { nil }
let(:question_definition) { nil }
let(:page) { instance_double(Form::Page) }
it "has correct page" do
expect(question.page).to eq(page)
end
it "has the correct id" do
expect(question.id).to eq("combined_income_value_check")
end
it "has the correct header" do
expect(question.header).to eq("Are you sure this is correct?")
end
it "has the correct check_answer_label" do
expect(question.check_answer_label).to eq("Combined income confirmation")
end
it "has the correct type" do
expect(question.type).to eq("interruption_screen")
end
it "is not marked as derived" do
expect(question.derived?).to be false
end
it "has the correct hint" do
expect(question.hint_text).to be_nil
end
it "has a correct check_answers_card_number" do
expect(question.check_answers_card_number).to eq(nil)
end
it "has the correct answer_options" do
expect(question.answer_options).to eq({
"0" => { "value" => "Yes" },
"1" => { "value" => "No" },
})
end
it "has the correct hidden_in_check_answers" do
expect(question.hidden_in_check_answers).to eq({
"depends_on" => [
{
"combined_income_value_check" => 0,
},
{
"combined_income_value_check" => 1,
},
],
})
end
end

8
spec/models/form/sales/subsections/household_characteristics_spec.rb

@ -37,7 +37,7 @@ RSpec.describe Form::Sales::Subsections::HouseholdCharacteristics, type: :model
buyer_1_nationality buyer_1_nationality
buyer_1_working_situation buyer_1_working_situation
working_situation_1_retirement_value_check working_situation_1_retirement_value_check
working_situation_buyer_1_income_value_check working_situation_buyer_1_income_min_value_check
buyer_1_live_in_property buyer_1_live_in_property
buyer_1_live_in_property_value_check buyer_1_live_in_property_value_check
buyer_2_relationship_to_buyer_1 buyer_2_relationship_to_buyer_1
@ -50,7 +50,7 @@ RSpec.describe Form::Sales::Subsections::HouseholdCharacteristics, type: :model
gender_2_buyer_retirement_value_check gender_2_buyer_retirement_value_check
buyer_2_working_situation buyer_2_working_situation
working_situation_2_retirement_value_check_joint_purchase working_situation_2_retirement_value_check_joint_purchase
working_situation_buyer_2_income_value_check working_situation_buyer_2_income_min_value_check
buyer_2_working_situation_student_not_child_value_check buyer_2_working_situation_student_not_child_value_check
buyer_2_live_in_property buyer_2_live_in_property
buyer_2_live_in_property_value_check buyer_2_live_in_property_value_check
@ -141,7 +141,7 @@ RSpec.describe Form::Sales::Subsections::HouseholdCharacteristics, type: :model
buyer_1_nationality buyer_1_nationality
buyer_1_working_situation buyer_1_working_situation
working_situation_1_retirement_value_check working_situation_1_retirement_value_check
working_situation_buyer_1_income_value_check working_situation_buyer_1_income_min_value_check
buyer_1_live_in_property buyer_1_live_in_property
buyer_1_live_in_property_value_check buyer_1_live_in_property_value_check
buyer_2_relationship_to_buyer_1 buyer_2_relationship_to_buyer_1
@ -161,7 +161,7 @@ RSpec.describe Form::Sales::Subsections::HouseholdCharacteristics, type: :model
buyer_2_nationality buyer_2_nationality
buyer_2_working_situation buyer_2_working_situation
working_situation_2_retirement_value_check_joint_purchase working_situation_2_retirement_value_check_joint_purchase
working_situation_buyer_2_income_value_check working_situation_buyer_2_income_min_value_check
buyer_2_working_situation_student_not_child_value_check buyer_2_working_situation_student_not_child_value_check
buyer_2_live_in_property buyer_2_live_in_property
buyer_2_live_in_property_value_check buyer_2_live_in_property_value_check

16
spec/models/form/sales/subsections/income_benefits_and_savings_spec.rb

@ -21,13 +21,17 @@ RSpec.describe Form::Sales::Subsections::IncomeBenefitsAndSavings, type: :model
expect(subsection.pages.compact.map(&:id)).to eq( expect(subsection.pages.compact.map(&:id)).to eq(
%w[ %w[
buyer_1_income buyer_1_income
buyer_1_income_value_check buyer_1_income_min_value_check
buyer_1_income_max_value_check
buyer_1_combined_income_max_value_check
buyer_1_income_mortgage_value_check buyer_1_income_mortgage_value_check
buyer_1_mortgage buyer_1_mortgage
buyer_1_mortgage_value_check buyer_1_mortgage_value_check
buyer_2_income buyer_2_income
buyer_2_income_mortgage_value_check buyer_2_income_mortgage_value_check
buyer_2_income_value_check buyer_2_income_min_value_check
buyer_2_income_max_value_check
buyer_2_combined_income_max_value_check
buyer_2_mortgage buyer_2_mortgage
buyer_2_mortgage_value_check buyer_2_mortgage_value_check
housing_benefits_joint_purchase housing_benefits_joint_purchase
@ -49,13 +53,17 @@ RSpec.describe Form::Sales::Subsections::IncomeBenefitsAndSavings, type: :model
expect(subsection.pages.map(&:id)).to eq( expect(subsection.pages.map(&:id)).to eq(
%w[ %w[
buyer_1_income buyer_1_income
buyer_1_income_value_check buyer_1_income_min_value_check
buyer_1_income_max_value_check
buyer_1_combined_income_max_value_check
buyer_1_income_mortgage_value_check buyer_1_income_mortgage_value_check
buyer_1_mortgage buyer_1_mortgage
buyer_1_mortgage_value_check buyer_1_mortgage_value_check
buyer_2_income buyer_2_income
buyer_2_income_mortgage_value_check buyer_2_income_mortgage_value_check
buyer_2_income_value_check buyer_2_income_min_value_check
buyer_2_income_max_value_check
buyer_2_combined_income_max_value_check
buyer_2_mortgage buyer_2_mortgage
buyer_2_mortgage_value_check buyer_2_mortgage_value_check
housing_benefits_joint_purchase housing_benefits_joint_purchase

6
spec/models/form/sales/subsections/property_information_spec.rb

@ -28,6 +28,9 @@ RSpec.describe Form::Sales::Subsections::PropertyInformation, type: :model do
property_building_type property_building_type
property_postcode property_postcode
property_local_authority property_local_authority
local_authority_buyer_1_income_max_value_check
local_authority_buyer_2_income_max_value_check
local_authority_combined_income_max_value_check
about_price_la_value_check about_price_la_value_check
property_wheelchair_accessible property_wheelchair_accessible
], ],
@ -51,6 +54,9 @@ RSpec.describe Form::Sales::Subsections::PropertyInformation, type: :model do
uprn_confirmation uprn_confirmation
address address
property_local_authority property_local_authority
local_authority_buyer_1_income_max_value_check
local_authority_buyer_2_income_max_value_check
local_authority_combined_income_max_value_check
about_price_la_value_check about_price_la_value_check
property_wheelchair_accessible property_wheelchair_accessible
], ],

Loading…
Cancel
Save