Browse Source

CLDC-3654: Copy changes - Sales property information questions (#2694)

pull/2738/head^2
Manny Dinssa 3 months ago committed by GitHub
parent
commit
f9922c1ba4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 3
      app/helpers/formatting_helper.rb
  2. 14
      app/models/form/lettings/pages/property_postcode.rb
  3. 15
      app/models/form/lettings/questions/postcode_full.rb
  4. 17
      app/models/form/lettings/questions/postcode_known.rb
  5. 6
      app/models/form/lettings/subsections/property_information.rb
  6. 5
      app/models/form/sales/pages/about_price_value_check.rb
  7. 2
      app/models/form/sales/pages/address.rb
  8. 2
      app/models/form/sales/pages/address_fallback.rb
  9. 2
      app/models/form/sales/pages/address_matcher.rb
  10. 5
      app/models/form/sales/pages/monthly_charges_value_check.rb
  11. 5
      app/models/form/sales/pages/no_address_found.rb
  12. 7
      app/models/form/sales/pages/percentage_discount_value_check.rb
  13. 13
      app/models/form/sales/pages/postcode.rb
  14. 9
      app/models/form/sales/pages/property_local_authority.rb
  15. 1
      app/models/form/sales/pages/uprn.rb
  16. 1
      app/models/form/sales/pages/uprn_confirmation.rb
  17. 1
      app/models/form/sales/pages/uprn_selection.rb
  18. 3
      app/models/form/sales/questions/about_price_value_check.rb
  19. 3
      app/models/form/sales/questions/address_line1.rb
  20. 3
      app/models/form/sales/questions/address_line1_for_address_matcher.rb
  21. 2
      app/models/form/sales/questions/address_line2.rb
  22. 3
      app/models/form/sales/questions/county.rb
  23. 3
      app/models/form/sales/questions/monthly_charges_value_check.rb
  24. 2
      app/models/form/sales/questions/no_address_found.rb
  25. 3
      app/models/form/sales/questions/percentage_discount_value_check.rb
  26. 22
      app/models/form/sales/questions/postcode.rb
  27. 2
      app/models/form/sales/questions/postcode_for_address_matcher.rb
  28. 3
      app/models/form/sales/questions/postcode_for_full_address.rb
  29. 29
      app/models/form/sales/questions/postcode_known.rb
  30. 3
      app/models/form/sales/questions/property_building_type.rb
  31. 2
      app/models/form/sales/questions/property_local_authority.rb
  32. 26
      app/models/form/sales/questions/property_local_authority_known.rb
  33. 4
      app/models/form/sales/questions/property_number_of_bedrooms.rb
  34. 3
      app/models/form/sales/questions/property_unit_type.rb
  35. 4
      app/models/form/sales/questions/property_wheelchair_accessible.rb
  36. 3
      app/models/form/sales/questions/town_or_city.rb
  37. 3
      app/models/form/sales/questions/uprn.rb
  38. 2
      app/models/form/sales/questions/uprn_confirmation.rb
  39. 6
      app/models/form/sales/questions/uprn_known.rb
  40. 2
      app/models/form/sales/questions/uprn_selection.rb
  41. 12
      app/models/form/sales/subsections/property_information.rb
  42. 14
      config/locales/en.yml
  43. 74
      config/locales/forms/2023/sales/property_information.en.yml
  44. 33
      config/locales/forms/2023/sales/soft_validations.en.yml
  45. 91
      config/locales/forms/2024/sales/property_information.en.yml
  46. 41
      config/locales/forms/2024/sales/soft_validations.en.yml
  47. 7
      spec/models/form/sales/pages/about_price_value_check_spec.rb
  48. 7
      spec/models/form/sales/pages/monthly_charges_value_check_spec.rb
  49. 7
      spec/models/form/sales/pages/no_address_found_spec.rb
  50. 7
      spec/models/form/sales/pages/percentage_discount_value_check_spec.rb
  51. 29
      spec/models/form/sales/pages/postcode_spec.rb
  52. 13
      spec/models/form/sales/pages/property_local_authority_spec.rb
  53. 47
      spec/models/form/sales/questions/postcode_known_spec.rb
  54. 46
      spec/models/form/sales/questions/postcode_spec.rb
  55. 6
      spec/models/form/sales/questions/uprn_confirmation_spec.rb
  56. 4
      spec/models/form/sales/questions/uprn_known_spec.rb
  57. 24
      spec/models/form/sales/subsections/property_information_spec.rb

3
app/helpers/formatting_helper.rb

@ -2,7 +2,8 @@ module FormattingHelper
def format_ending(text)
return text if text.blank?
modified_text = lowercase_first_letter(text)
first_word = text.split.first
modified_text = first_word == first_word.upcase ? text : lowercase_first_letter(text)
ensure_sentence_ending(modified_text)
end

14
app/models/form/lettings/pages/property_postcode.rb

@ -1,14 +0,0 @@
class Form::Lettings::Pages::PropertyPostcode < ::Form::Page
def initialize(id, hsh, subsection)
super
@id = "property_postcode"
@depends_on = [{ "is_general_needs?" => true }]
end
def questions
@questions ||= [
Form::Lettings::Questions::PostcodeKnown.new(nil, nil, self),
Form::Lettings::Questions::PostcodeFull.new(nil, nil, self),
]
end
end

15
app/models/form/lettings/questions/postcode_full.rb

@ -1,15 +0,0 @@
class Form::Lettings::Questions::PostcodeFull < ::Form::Question
def initialize(id, hsh, page)
super
@id = "postcode_full"
@check_answer_label = "Postcode"
@header = "What is the property’s postcode?"
@type = "text"
@width = 5
@inferred_check_answers_value = [{ "condition" => { "postcode_known" => 0 }, "value" => "Not known" }]
@check_answers_card_number = 0
@hint_text = ""
@inferred_answers = { "la" => { "is_la_inferred" => true } }
@disable_clearing_if_not_routed_or_dynamic_answer_options = true
end
end

17
app/models/form/lettings/questions/postcode_known.rb

@ -1,17 +0,0 @@
class Form::Lettings::Questions::PostcodeKnown < ::Form::Question
def initialize(id, hsh, page)
super
@id = "postcode_known"
@check_answer_label = "Do you know the property postcode?"
@header = "Do you know the property’s postcode?"
@type = "radio"
@check_answers_card_number = 0
@hint_text = ""
@answer_options = ANSWER_OPTIONS
@disable_clearing_if_not_routed_or_dynamic_answer_options = true
@conditional_for = { "postcode_full" => [1] }
@hidden_in_check_answers = { "depends_on" => [{ "postcode_known" => 0 }, { "postcode_known" => 1 }] }
end
ANSWER_OPTIONS = { "1" => { "value" => "Yes" }, "0" => { "value" => "No" } }.freeze
end

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

@ -38,16 +38,12 @@ class Form::Lettings::Subsections::PropertyInformation < ::Form::Subsection
Form::Lettings::Pages::UprnSelection.new(nil, nil, self),
Form::Lettings::Pages::AddressFallback.new(nil, nil, self),
]
elsif form.start_date.year == 2023
else
[
Form::Lettings::Pages::Uprn.new(nil, nil, self),
Form::Lettings::Pages::UprnConfirmation.new(nil, nil, self),
Form::Lettings::Pages::Address.new(nil, nil, self),
]
else
[
Form::Lettings::Pages::PropertyPostcode.new(nil, nil, self),
]
end
end

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

@ -6,8 +6,9 @@ class Form::Sales::Pages::AboutPriceValueCheck < ::Form::Page
"purchase_price_out_of_soft_range?" => true,
},
]
@copy_key = "sales.soft_validations.value_value_check"
@title_text = {
"translation" => "soft_validations.purchase_price.title_text",
"translation" => "forms.#{form.start_date.year}.#{@copy_key}.title_text",
"arguments" => [
{
"key" => "value",
@ -17,7 +18,7 @@ class Form::Sales::Pages::AboutPriceValueCheck < ::Form::Page
],
}
@informative_text = {
"translation" => "soft_validations.purchase_price.hint_text",
"translation" => "forms.#{form.start_date.year}.#{@copy_key}.informative_text",
"arguments" => [
{
"key" => "field_formatted_as_currency",

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

@ -2,7 +2,7 @@ class Form::Sales::Pages::Address < ::Form::Page
def initialize(id, hsh, subsection)
super
@id = "address"
@header = "Q#{QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max]} - What is the property's address?"
@copy_key = "sales.property_information.address"
@depends_on = [
{ "uprn_known" => nil },
{ "uprn_known" => 0 },

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

@ -2,7 +2,7 @@ class Form::Sales::Pages::AddressFallback < ::Form::Page
def initialize(id, hsh, subsection)
super
@id = "address"
@header = "Q12 - What is the property's address?"
@copy_key = "sales.property_information.address"
@depends_on = [
{ "uprn_known" => nil, "uprn_selection" => "uprn_not_listed" },
{ "uprn_known" => 0, "uprn_selection" => "uprn_not_listed" },

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

@ -2,7 +2,7 @@ class Form::Sales::Pages::AddressMatcher < ::Form::Page
def initialize(id, hsh, subsection)
super
@id = "address_matcher"
@header = "Find an address"
@copy_key = "sales.property_information.address_matcher"
@depends_on = [
{ "uprn_known" => nil },
{ "uprn_known" => 0 },

5
app/models/form/sales/pages/monthly_charges_value_check.rb

@ -6,8 +6,9 @@ class Form::Sales::Pages::MonthlyChargesValueCheck < ::Form::Page
"monthly_charges_over_soft_max?" => true,
},
]
@copy_key = "sales.soft_validations.monthly_charges_value_check"
@title_text = {
"translation" => "soft_validations.monthly_charges_over_soft_max.title_text",
"translation" => "forms.#{form.start_date.year}.#{@copy_key}.title_text",
"arguments" => [
{
"key" => "field_formatted_as_currency",
@ -17,7 +18,7 @@ class Form::Sales::Pages::MonthlyChargesValueCheck < ::Form::Page
],
}
@informative_text = {
"translation" => "soft_validations.monthly_charges_over_soft_max.hint_text",
"translation" => "forms.#{form.start_date.year}.#{@copy_key}.informative_text",
"arguments" => [],
}
end

5
app/models/form/sales/pages/no_address_found.rb

@ -3,12 +3,13 @@ class Form::Sales::Pages::NoAddressFound < ::Form::Page
super
@id = "no_address_found"
@type = "interruption_screen"
@copy_key = "sales.soft_validations.address_search_value_check"
@title_text = {
"translation" => "soft_validations.no_address_found.title_text",
"translation" => "forms.#{form.start_date.year}.#{@copy_key}.title_text",
"arguments" => [],
}
@informative_text = {
"translation" => "soft_validations.no_address_found.informative_text",
"translation" => "forms.#{form.start_date.year}.#{@copy_key}.informative_text",
"arguments" => [],
}
@depends_on = [

7
app/models/form/sales/pages/percentage_discount_value_check.rb

@ -1,15 +1,16 @@
class Form::Sales::Pages::PercentageDiscountValueCheck < ::Form::Page
def initialize(id, hsh, subsection)
super
@depends_on = [{ "percentage_discount_invalid?" => true }]
@copy_key = "sales.soft_validations.percentage_discount_value_check"
@title_text = {
"translation" => "soft_validations.percentage_discount_value.title_text",
"translation" => "forms.#{form.start_date.year}.#{@copy_key}.title_text",
"arguments" => [{ "key" => "discount", "label" => true, "i18n_template" => "discount" }],
}
@informative_text = {
"translation" => "soft_validations.percentage_discount_value.hint_text",
"translation" => "forms.#{form.start_date.year}.#{@copy_key}.informative_text",
"arguments" => [],
}
@depends_on = [{ "percentage_discount_invalid?" => true }]
end
def questions

13
app/models/form/sales/pages/postcode.rb

@ -1,13 +0,0 @@
class Form::Sales::Pages::Postcode < ::Form::Page
def initialize(id, hsh, subsection)
super
@id = "property_postcode"
end
def questions
@questions ||= [
Form::Sales::Questions::PostcodeKnown.new(nil, nil, self),
Form::Sales::Questions::Postcode.new(nil, nil, self),
]
end
end

9
app/models/form/sales/pages/property_local_authority.rb

@ -10,14 +10,7 @@ class Form::Sales::Pages::PropertyLocalAuthority < ::Form::Page
def questions
@questions ||= [
la_known_question,
Form::Sales::Questions::PropertyLocalAuthority.new(nil, nil, self),
].compact
end
def la_known_question
if form.start_date.year < 2023
Form::Sales::Questions::PropertyLocalAuthorityKnown.new(nil, nil, self)
end
]
end
end

1
app/models/form/sales/pages/uprn.rb

@ -2,6 +2,7 @@ class Form::Sales::Pages::Uprn < ::Form::Page
def initialize(id, hsh, subsection)
super
@id = "uprn"
@copy_key = "sales.property_information.uprn"
end
def questions

1
app/models/form/sales/pages/uprn_confirmation.rb

@ -2,7 +2,6 @@ class Form::Sales::Pages::UprnConfirmation < ::Form::Page
def initialize(id, hsh, subsection)
super
@id = "uprn_confirmation"
@header = "We found an address that might be this property"
end
def questions

1
app/models/form/sales/pages/uprn_selection.rb

@ -2,7 +2,6 @@ class Form::Sales::Pages::UprnSelection < ::Form::Page
def initialize(id, hsh, subsection)
super
@id = "uprn_selection"
@header = "We found some addresses that might be this property"
@depends_on = [
{ "uprn_known" => nil, "address_options_present?" => true },
{ "uprn_known" => 0, "address_options_present?" => true },

3
app/models/form/sales/questions/about_price_value_check.rb

@ -2,8 +2,7 @@ class Form::Sales::Questions::AboutPriceValueCheck < ::Form::Question
def initialize(id, hsh, page)
super
@id = "value_value_check"
@check_answer_label = "Purchase price confirmation"
@header = "Are you sure?"
@copy_key = "sales.soft_validations.value_value_check"
@type = "interruption_screen"
@answer_options = {
"0" => { "value" => "Yes" },

3
app/models/form/sales/questions/address_line1.rb

@ -2,11 +2,10 @@ class Form::Sales::Questions::AddressLine1 < ::Form::Question
def initialize(id, hsh, page)
super
@id = "address_line1"
@header = "Address line 1"
@copy_key = "sales.property_information.address.address_line1"
@error_label = "Address line 1"
@type = "text"
@plain_label = true
@check_answer_label = "Address lines 1 and 2"
@disable_clearing_if_not_routed_or_dynamic_answer_options = true
@question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max]
@hide_question_number_on_page = true

3
app/models/form/sales/questions/address_line1_for_address_matcher.rb

@ -2,11 +2,10 @@ class Form::Sales::Questions::AddressLine1ForAddressMatcher < ::Form::Question
def initialize(id, hsh, page)
super
@id = "address_line1_input"
@header = "Address line 1"
@copy_key = "sales.property_information.address_matcher.address_line1_input"
@error_label = "Address line 1"
@type = "text"
@plain_label = true
@check_answer_label = "Find address"
@disable_clearing_if_not_routed_or_dynamic_answer_options = true
@hide_question_number_on_page = true
end

2
app/models/form/sales/questions/address_line2.rb

@ -2,7 +2,7 @@ class Form::Sales::Questions::AddressLine2 < ::Form::Question
def initialize(id, hsh, page)
super
@id = "address_line2"
@header = "Address line 2 (optional)"
@copy_key = "sales.property_information.address.address_line2"
@type = "text"
@plain_label = true
@disable_clearing_if_not_routed_or_dynamic_answer_options = true

3
app/models/form/sales/questions/county.rb

@ -2,10 +2,9 @@ class Form::Sales::Questions::County < ::Form::Question
def initialize(id, hsh, page)
super
@id = "county"
@header = "County (optional)"
@copy_key = "sales.property_information.address.county"
@type = "text"
@plain_label = true
@check_answer_label = "County"
@disable_clearing_if_not_routed_or_dynamic_answer_options = true
@question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max]
@hide_question_number_on_page = true

3
app/models/form/sales/questions/monthly_charges_value_check.rb

@ -2,8 +2,7 @@ class Form::Sales::Questions::MonthlyChargesValueCheck < ::Form::Question
def initialize(id, hsh, page)
super
@id = "monthly_charges_value_check"
@check_answer_label = "Monthly charges confirmation"
@header = "Are you sure this is correct?"
@copy_key = "sales.soft_validations.monthly_charges_value_check"
@type = "interruption_screen"
@answer_options = {
"0" => { "value" => "Yes" },

2
app/models/form/sales/questions/no_address_found.rb

@ -2,7 +2,7 @@ class Form::Sales::Questions::NoAddressFound < ::Form::Question
def initialize(id, hsh, page)
super
@id = "address_search_value_check"
@header = "No address found"
@copy_key = "sales.soft_validations.address_search_value_check"
@type = "interruption_screen"
@hidden_in_check_answers = true
end

3
app/models/form/sales/questions/percentage_discount_value_check.rb

@ -2,8 +2,7 @@ class Form::Sales::Questions::PercentageDiscountValueCheck < ::Form::Question
def initialize(id, hsh, page)
super
@id = "percentage_discount_value_check"
@check_answer_label = "Percentage discount confirmation"
@header = "Are you sure this is correct?"
@copy_key = "sales.soft_validations.percentage_discount_value_check"
@type = "interruption_screen"
@answer_options = {
"0" => { "value" => "Yes" },

22
app/models/form/sales/questions/postcode.rb

@ -1,22 +0,0 @@
class Form::Sales::Questions::Postcode < ::Form::Question
def initialize(id, hsh, page)
super
@id = "postcode_full"
@check_answer_label = "Property’s postcode"
@header = "Postcode"
@type = "text"
@width = 5
@inferred_check_answers_value = [{
"condition" => {
"pcodenk" => 1,
},
"value" => "Not known",
}]
@inferred_answers = {
"la" => {
"is_la_inferred" => true,
},
}
@disable_clearing_if_not_routed_or_dynamic_answer_options = true
end
end

2
app/models/form/sales/questions/postcode_for_address_matcher.rb

@ -2,7 +2,7 @@ class Form::Sales::Questions::PostcodeForAddressMatcher < ::Form::Question
def initialize(id, hsh, page)
super
@id = "postcode_full_input"
@header = "Postcode"
@copy_key = "sales.property_information.address_matcher.postcode_full_input"
@type = "text"
@width = 5
@plain_label = true

3
app/models/form/sales/questions/postcode_for_full_address.rb

@ -2,7 +2,7 @@ class Form::Sales::Questions::PostcodeForFullAddress < ::Form::Question
def initialize(id, hsh, page)
super
@id = "postcode_full"
@header = "Postcode"
@copy_key = "sales.property_information.address.postcode_full"
@type = "text"
@width = 5
@inferred_check_answers_value = [{
@ -17,7 +17,6 @@ class Form::Sales::Questions::PostcodeForFullAddress < ::Form::Question
},
}
@plain_label = true
@check_answer_label = "Postcode"
@disable_clearing_if_not_routed_or_dynamic_answer_options = true
@question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max]
@hide_question_number_on_page = true

29
app/models/form/sales/questions/postcode_known.rb

@ -1,29 +0,0 @@
class Form::Sales::Questions::PostcodeKnown < ::Form::Question
def initialize(id, hsh, page)
super
@id = "pcodenk"
@check_answer_label = "Property’s postcode"
@header = "Do you know the property’s postcode?"
@type = "radio"
@answer_options = ANSWER_OPTIONS
@conditional_for = {
"postcode_full" => [0],
}
@hidden_in_check_answers = {
"depends_on" => [
{
"pcodenk" => 0,
},
{
"pcodenk" => 1,
},
],
}
@disable_clearing_if_not_routed_or_dynamic_answer_options = true
end
ANSWER_OPTIONS = {
"0" => { "value" => "Yes" },
"1" => { "value" => "No" },
}.freeze
end

3
app/models/form/sales/questions/property_building_type.rb

@ -2,8 +2,7 @@ class Form::Sales::Questions::PropertyBuildingType < ::Form::Question
def initialize(id, hsh, page)
super
@id = "builtype"
@check_answer_label = "Type of building"
@header = "What type of building is the property?"
@copy_key = "sales.property_information.builtype"
@type = "radio"
@answer_options = ANSWER_OPTIONS
@question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max]

2
app/models/form/sales/questions/property_local_authority.rb

@ -2,8 +2,6 @@ class Form::Sales::Questions::PropertyLocalAuthority < ::Form::Question
def initialize(id, hsh, page)
super
@id = "la"
@check_answer_label = "Local authority"
@header = "What is the property’s local authority?"
@type = "select"
@question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max]
@disable_clearing_if_not_routed_or_dynamic_answer_options = true

26
app/models/form/sales/questions/property_local_authority_known.rb

@ -1,26 +0,0 @@
class Form::Sales::Questions::PropertyLocalAuthorityKnown < ::Form::Question
def initialize(id, hsh, page)
super
@id = "la_known"
@check_answer_label = "Local authority known"
@header = "Do you know the property’s local authority?"
@type = "radio"
@answer_options = ANSWER_OPTIONS
@conditional_for = { "la" => [1] }
@hidden_in_check_answers = {
"depends_on" => [
{
"la_known" => 1,
},
],
}
@question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max]
end
ANSWER_OPTIONS = {
"1" => { "value" => "Yes" },
"0" => { "value" => "No" },
}.freeze
QUESTION_NUMBER_FROM_YEAR = { 2023 => 16, 2024 => 17 }.freeze
end

4
app/models/form/sales/questions/property_number_of_bedrooms.rb

@ -2,9 +2,7 @@ class Form::Sales::Questions::PropertyNumberOfBedrooms < ::Form::Question
def initialize(id, hsh, page)
super
@id = "beds"
@check_answer_label = "Number of bedrooms"
@header = "How many bedrooms does the property have?"
@hint_text = "A bedsit has 1 bedroom"
@copy_key = "sales.property_information.beds"
@type = "numeric"
@width = 2
@min = 1

3
app/models/form/sales/questions/property_unit_type.rb

@ -2,8 +2,7 @@ class Form::Sales::Questions::PropertyUnitType < ::Form::Question
def initialize(id, hsh, page)
super
@id = "proptype"
@check_answer_label = "Type of unit"
@header = "What type of unit is the property?"
@copy_key = "sales.property_information.proptype"
@type = "radio"
@answer_options = ANSWER_OPTIONS
@question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max]

4
app/models/form/sales/questions/property_wheelchair_accessible.rb

@ -2,12 +2,10 @@ class Form::Sales::Questions::PropertyWheelchairAccessible < ::Form::Question
def initialize(id, hsh, page)
super
@id = "wchair"
@check_answer_label = "Property built or adapted to wheelchair-user standards"
@header = "Is the property built or adapted to wheelchair-user standards?"
@copy_key = "sales.property_information.wchair"
@type = "radio"
@answer_options = ANSWER_OPTIONS
@question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max]
@hint_text = form.start_year_after_2024? ? "This is whether someone who uses a wheelchair is able to make full use of all of the property’s rooms and facilities, including use of both inside and outside space, and entering and exiting the property." : nil
end
ANSWER_OPTIONS = {

3
app/models/form/sales/questions/town_or_city.rb

@ -2,10 +2,9 @@ class Form::Sales::Questions::TownOrCity < ::Form::Question
def initialize(id, hsh, page)
super
@id = "town_or_city"
@header = "Town or city"
@copy_key = "sales.property_information.address.town_or_city"
@type = "text"
@plain_label = true
@check_answer_label = "Town or city"
@disable_clearing_if_not_routed_or_dynamic_answer_options = true
@question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max]
@hide_question_number_on_page = true

3
app/models/form/sales/questions/uprn.rb

@ -2,8 +2,7 @@ class Form::Sales::Questions::Uprn < ::Form::Question
def initialize(id, hsh, page)
super
@id = "uprn"
@check_answer_label = "UPRN"
@header = "What is the property's UPRN?"
@copy_key = "sales.property_information.uprn.uprn"
@type = "text"
@width = 10
@question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max]

2
app/models/form/sales/questions/uprn_confirmation.rb

@ -2,9 +2,7 @@ class Form::Sales::Questions::UprnConfirmation < ::Form::Question
def initialize(id, hsh, page)
super
@id = "uprn_confirmed"
@header = "Is this the property address?"
@type = "radio"
@check_answer_label = "Is this the right address?"
end
def answer_options

6
app/models/form/sales/questions/uprn_known.rb

@ -2,13 +2,9 @@ class Form::Sales::Questions::UprnKnown < ::Form::Question
def initialize(id, hsh, page)
super
@id = "uprn_known"
@check_answer_label = "UPRN known?"
@header = "Do you know the property's UPRN?"
@copy_key = "sales.property_information.uprn.uprn_known"
@type = "radio"
@answer_options = ANSWER_OPTIONS
@hint_text = "The Unique Property Reference Number (UPRN) is a unique number system created by Ordnance Survey and used by housing providers and various industries across the UK. An example UPRN is 10010457355.<br><br>
The UPRN may not be the same as the property reference assigned by your organisation.<br><br>
If you dont know the UPRN you can enter the address of the property instead on the next screen."
@conditional_for = { "uprn" => [1] }
@inferred_check_answers_value = [
{

2
app/models/form/sales/questions/uprn_selection.rb

@ -2,9 +2,7 @@ class Form::Sales::Questions::UprnSelection < ::Form::Question
def initialize(id, hsh, page)
super
@id = "uprn_selection"
@header = "Select the correct address"
@type = "radio"
@check_answer_label = "Select the correct address"
@disable_clearing_if_not_routed_or_dynamic_answer_options = true
end

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

@ -16,7 +16,6 @@ class Form::Sales::Subsections::PropertyInformation < ::Form::Subsection
Form::Sales::Pages::PercentageDiscountValueCheck.new("percentage_discount_proptype_value_check", nil, self),
Form::Sales::Pages::PropertyBuildingType.new(nil, nil, self),
(uprn_questions if form.start_date.year == 2023),
(postcode_and_la_questions if form.start_date.year < 2023),
Form::Sales::Pages::PropertyWheelchairAccessible.new(nil, nil, self),
].flatten.compact
end
@ -49,15 +48,4 @@ class Form::Sales::Subsections::PropertyInformation < ::Form::Subsection
]
end
end
def postcode_and_la_questions
[
Form::Sales::Pages::Postcode.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),
Form::Sales::Pages::AboutPriceValueCheck.new("about_price_la_value_check", nil, self),
]
end
end

14
config/locales/en.yml

@ -234,7 +234,7 @@ en:
scheme_deleted: "%{service_name} has been deleted."
user_deleted: "%{name} has been deleted."
organisation_deleted: "%{name} has been deleted."
user_updated:
user_updated:
self: "Your account details have been updated."
other: "%{name}’s details have been updated."
@ -650,9 +650,6 @@ en:
outside_range_title: "You told us the rent is %{brent}."
informative_text: "This is %{higher_or_lower} than we would expect."
hint_text: "Check the following:<ul class=\"govuk-body-l app-panel--interruption\"><li>the decimal point</li><li>the frequency, for example every week or every calendar month</li><li>the rent type is correct, for example affordable or social rent</li></ul>"
purchase_price:
title_text: "You told us the purchase price is %{value}."
hint_text: "This is %{higher_or_lower} than we would expect."
staircase_owned:
title_text:
one: "You told us that the buyer now owns %{stairowned} of the property."
@ -684,17 +681,11 @@ Make sure these answers are correct."
staircase_bought_seems_high:
title_text: "You told us that %{percentage}% was bought in this staircasing transaction."
hint_text: "Most staircasing transactions are less than 50%"
monthly_charges_over_soft_max:
title_text: "You told us that the monthly charges were %{mscharge}."
hint_text: "This is higher than we would expect."
discounted_sale_value:
title_text: "Mortgage, deposit, and grant total must equal %{value_with_discount}."
informative_text: "Your given mortgage, deposit and grant total is %{mortgage_deposit_and_grant_total}."
care_home_charges:
title_text: "Care home charges should be provided if this is a care home accommodation."
percentage_discount_value:
title_text: "You told us that the percentage discount is %{discount}."
hint_text: "This is higher than we would expect."
grant:
title_text: "You told us that the grant amount is %{grant}."
hint_text: "Loans, grants and subsidies are usually between £9,000 and £16,000."
@ -722,9 +713,6 @@ Make sure these answers are correct."
must_be_less_than_3_years_from_saledate: "You told us practical completion or handover date is more than 3 years before sale completion date."
saledate:
must_be_less_than_3_years_from_hodate: "You told us sale completion date is more than 3 years after practical completion or handover date."
no_address_found:
title_text: "No address found."
informative_text: "We could not find an address that matches your search. You can search again or continue to enter the address manually."
partner_under_16_lettings:
title: "You told us this person is aged %{age} years and has 'Partner' relationship to the lead tenant."
multiple_partners_lettings:

74
config/locales/forms/2023/sales/property_information.en.yml

@ -0,0 +1,74 @@
en:
forms:
2023:
sales:
property_information:
uprn:
page_header: ""
uprn_known:
check_answer_label: "UPRN known?"
hint_text: "The Unique Property Reference Number (UPRN) is a unique number system created by Ordnance Survey and used by housing providers and various industries across the UK. An example UPRN is 10010457355.<br><br>The UPRN may not be the same as the property reference assigned by your organisation.<br><br>If you don’t know the UPRN you can enter the address of the property instead on the next screen."
question_text: "Do you know the property's UPRN?"
uprn:
check_answer_label: "UPRN"
hint_text: ""
question_text: "What is the property's UPRN?"
uprn_confirmed:
page_header: "We found an address that might be this property"
check_answer_label: "Is this the right address?"
hint_text: ""
question_text: "Is this the property address?"
address:
page_header: "Q15 - What is the property's address?"
address_line1:
check_answer_label: "Address lines 1 and 2"
hint_text: ""
question_text: "Address line 1"
address_line2:
check_answer_label: ""
hint_text: ""
question_text: "Address line 2 (optional)"
town_or_city:
check_answer_label: "Town or city"
hint_text: ""
question_text: "Town or city"
county:
check_answer_label: "County"
hint_text: ""
question_text: "County (optional)"
postcode_full:
check_answer_label: "Postcode"
hint_text: ""
question_text: "Postcode"
la:
page_header: ""
check_answer_label: "Local authority"
hint_text: ""
question_text: "What is the property’s local authority?"
beds:
page_header: ""
check_answer_label: "Number of bedrooms"
hint_text: "A bedsit has 1 bedroom."
question_text: "How many bedrooms does the property have?"
proptype:
page_header: ""
check_answer_label: "Type of unit"
hint_text: ""
question_text: "What type of unit is the property?"
builtype:
page_header: ""
check_answer_label: "Type of building"
hint_text: ""
question_text: "What type of building is the property?"
wchair:
page_header: ""
check_answer_label: "Property built or adapted to wheelchair-user standards"
hint_text: ""
question_text: "Is the property built or adapted to wheelchair-user standards?"

33
config/locales/forms/2023/sales/soft_validations.en.yml

@ -38,6 +38,7 @@ en:
max:
page_header: ""
title_text: "You told us the income of buyer 1 is %{income}. This seems high. Are you sure this is correct?"
income2_value_check:
check_answer_label: "Buyer 2 income confirmation"
hint_text: ""
@ -49,12 +50,22 @@ en:
max:
page_header: ""
title_text: "You told us the income of buyer 2 is %{income}. This seems high. Are you sure this is correct?"
combined_income_value_check:
page_header: ""
check_answer_label: "Combined income confirmation"
hint_text: ""
question_text: "Are you sure this is correct?"
title_text: "You told us the combined income of this household is %{combined_income}. This seems high. Are you sure this is correct?"
value_value_check:
page_header: ""
check_answer_label: "Purchase price confirmation"
hint_text: ""
question_text: "Are you sure?"
title_text: "You told us the purchase price is %{value}."
informative_text: "This is %{higher_or_lower} than we would expect."
mortgage_value_check:
page_header: ""
check_answer_label: "Mortgage confirmation"
@ -62,18 +73,36 @@ en:
question_text: "Are you sure that the mortgage is more than 5 times the income used for the mortgage application?"
title_text: "You told us that the mortgage amount is %{mortgage}."
informative_text: "This is more than 5 times the income, which is higher than we would expect."
monthly_charges_value_check:
page_header: ""
check_answer_label: "Monthly charges confirmation"
hint_text: ""
question_text: "Are you sure this is correct?"
title_text: "You told us that the monthly charges were %{mscharge}."
informative_text: "This is higher than we would expect."
percentage_discount_value_check:
page_header: ""
check_answer_label: "Percentage discount confirmation"
hint_text: ""
question_text: "Are you sure this is correct?"
title_text: "You told us that the percentage discount is %{discount}."
informative_text: "This is higher than we would expect."
savings_value_check:
page_header: ""
check_answer_label: "Savings confirmation"
hint_text: ""
question_text: "Are you sure the savings are higher than £100,000?"
joint_purchase:
title_text: You told us the buyers’ savings were %{savings}."
title_text: "You told us the buyers’ savings were %{savings}."
informative_text: "This is higher than we would expect."
not_joint_purchase:
title_text: "You told us the buyer’s savings were %{savings}."
informative_text: "This is higher than we would expect."
deposit_value_check::
deposit_value_check:
page_header: ""
check_answer_label: "Deposit confirmation"
hint_text: ""

91
config/locales/forms/2024/sales/property_information.en.yml

@ -0,0 +1,91 @@
en:
forms:
2024:
sales:
property_information:
uprn:
page_header: ""
uprn_known:
check_answer_label: "UPRN known?"
hint_text: "The Unique Property Reference Number (UPRN) is a unique number system created by Ordnance Survey and used by housing providers and various industries across the UK. An example UPRN is 10010457355.<br><br>The UPRN may not be the same as the property reference assigned by your organisation.<br><br>If you don’t know the UPRN you can enter the address of the property instead on the next screen."
question_text: "Do you know the property's UPRN?"
uprn:
check_answer_label: "UPRN"
hint_text: ""
question_text: "What is the property's UPRN?"
uprn_confirmed:
page_header: "We found an address that might be this property"
check_answer_label: "Is this the right address?"
hint_text: ""
question_text: "Is this the property address?"
address_matcher:
page_header: "Find an address"
address_line1_input:
check_answer_label: "Find address"
hint_text: ""
question_text: "Address line 1"
postcode_full_input:
check_answer_label: ""
hint_text: ""
question_text: "Postcode"
uprn_selection:
page_header: "We found an address that might be this property"
check_answer_label: "Select the correct address"
hint_text: ""
question_text: "Select the correct address"
address:
page_header: "Q12 - What is the property's address?"
address_line1:
check_answer_label: "Address lines 1 and 2"
hint_text: ""
question_text: "Address line 1"
address_line2:
check_answer_label: ""
hint_text: ""
question_text: "Address line 2 (optional)"
town_or_city:
check_answer_label: "Town or city"
hint_text: ""
question_text: "Town or city"
county:
check_answer_label: "County"
hint_text: ""
question_text: "County (optional)"
postcode_full:
check_answer_label: "Postcode"
hint_text: ""
question_text: "Postcode"
la:
page_header: ""
check_answer_label: "Local authority"
hint_text: ""
question_text: "What is the property’s local authority?"
beds:
page_header: ""
check_answer_label: "Number of bedrooms"
hint_text: "A bedsit has 1 bedroom."
question_text: "How many bedrooms does the property have?"
proptype:
page_header: ""
check_answer_label: "Type of unit"
hint_text: ""
question_text: "What type of unit is the property?"
builtype:
page_header: ""
check_answer_label: "Type of building"
hint_text: ""
question_text: "What type of building is the property?"
wchair:
page_header: ""
check_answer_label: "Property built or adapted to wheelchair-user standards"
hint_text: "This is whether someone who uses a wheelchair is able to make full use of all of the property’s rooms and facilities, including use of both inside and outside space, and entering and exiting the property."
question_text: "Is the property built or adapted to wheelchair-user standards?"

41
config/locales/forms/2024/sales/soft_validations.en.yml

@ -38,6 +38,7 @@ en:
max:
page_header: ""
title_text: "You told us the income of buyer 1 is %{income}. This seems high. Are you sure this is correct?"
income2_value_check:
check_answer_label: "Buyer 2 income confirmation"
hint_text: ""
@ -49,12 +50,23 @@ en:
max:
page_header: ""
title_text: "You told us the income of buyer 2 is %{income}. This seems high. Are you sure this is correct?"
combined_income_value_check:
page_header: ""
check_answer_label: "Combined income confirmation"
hint_text: ""
question_text: "Are you sure this is correct?"
title_text: "You told us the combined income of this household is %{combined_income}. This seems high. Are you sure this is correct?"
informative_text: ""
value_value_check:
page_header: ""
check_answer_label: "Purchase price confirmation"
hint_text: ""
question_text: "Are you sure?"
title_text: "You told us the purchase price is %{value}."
informative_text: "This is %{higher_or_lower} than we would expect."
mortgage_value_check:
page_header: ""
check_answer_label: "Mortgage confirmation"
@ -62,17 +74,35 @@ en:
question_text: "Are you sure that the mortgage is more than 5 times the income used for the mortgage application?"
title_text: "You told us that the mortgage amount is %{mortgage}."
informative_text: "This is more than 5 times the income, which is higher than we would expect."
monthly_charges_value_check:
page_header: ""
check_answer_label: "Monthly charges confirmation"
hint_text: ""
question_text: "Are you sure this is correct?"
title_text: "You told us that the monthly charges were %{mscharge}."
informative_text: "This is higher than we would expect."
percentage_discount_value_check:
page_header: ""
check_answer_label: "Percentage discount confirmation"
hint_text: ""
question_text: "Are you sure this is correct?"
title_text: "You told us that the percentage discount is %{discount}."
informative_text: "This is higher than we would expect."
savings_value_check:
page_header: ""
check_answer_label: "Savings confirmation"
hint_text: ""
question_text: "Are you sure the savings are higher than £100,000?"
joint_purchase:
title_text: You told us the buyers’ savings were %{savings}."
title_text: "You told us the buyers’ savings were %{savings}."
informative_text: "This is higher than we would expect."
not_joint_purchase:
title_text: "You told us the buyer’s savings were %{savings}."
informative_text: "This is higher than we would expect."
deposit_value_check:
page_header: ""
check_answer_label: "Deposit confirmation"
@ -84,6 +114,15 @@ en:
not_joint_purchase:
title_text: "You told us the buyer’s deposit was %{deposit} and their savings were %{savings}."
informative_text: "The deposit amount is higher than we would expect for the amount of savings they have."
address_search_value_check:
page_header: ""
check_answer_label: ""
hint_text: ""
question_text: ""
title_text: "No address found."
informative_text: "We could not find an address that matches your search. You can search again or continue to enter the address manually."
wheel_value_check:
page_header: ""
check_answer_label: "Does anyone in the household use a wheelchair?"

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

@ -5,7 +5,8 @@ RSpec.describe Form::Sales::Pages::AboutPriceValueCheck, type: :model do
let(:page_id) { "savings_value_check" }
let(:page_definition) { nil }
let(:subsection) { instance_double(Form::Subsection) }
let(:form) { instance_double(Form, start_date: Time.zone.local(2024, 4, 1)) }
let(:subsection) { instance_double(Form::Subsection, form:) }
it "has correct subsection" do
expect(page.subsection).to eq(subsection)
@ -28,12 +29,12 @@ RSpec.describe Form::Sales::Pages::AboutPriceValueCheck, type: :model do
end
it "has the correct title_text" do
expect(page.title_text).to eq({ "arguments" => [{ "i18n_template" => "value", "key" => "value", "label" => true }], "translation" => "soft_validations.purchase_price.title_text" })
expect(page.title_text).to eq({ "arguments" => [{ "i18n_template" => "value", "key" => "value", "label" => true }], "translation" => "forms.2024.sales.soft_validations.value_value_check.title_text" })
end
it "has the correct informative_text" do
expect(page.informative_text).to eq({
"translation" => "soft_validations.purchase_price.hint_text",
"translation" => "forms.2024.sales.soft_validations.value_value_check.informative_text",
"arguments" => [
{
"key" => "field_formatted_as_currency",

7
spec/models/form/sales/pages/monthly_charges_value_check_spec.rb

@ -5,7 +5,8 @@ RSpec.describe Form::Sales::Pages::MonthlyChargesValueCheck, type: :model do
let(:page_id) { "monthly_charges_value_check" }
let(:page_definition) { nil }
let(:subsection) { instance_double(Form::Subsection) }
let(:form) { instance_double(Form, start_date: Time.zone.local(2024, 4, 1)) }
let(:subsection) { instance_double(Form::Subsection, form:) }
it "has correct subsection" do
expect(page.subsection).to eq(subsection)
@ -33,13 +34,13 @@ RSpec.describe Form::Sales::Pages::MonthlyChargesValueCheck, type: :model do
it "has correct title_text" do
expect(page.title_text).to eq({
"translation" => "soft_validations.monthly_charges_over_soft_max.title_text",
"translation" => "forms.2024.sales.soft_validations.monthly_charges_value_check.title_text",
"arguments" => [{ "arguments_for_key" => "mscharge", "i18n_template" => "mscharge", "key" => "field_formatted_as_currency" }],
})
end
it "has correct informative_text" do
expect(page.informative_text).to eq({ "arguments" => [], "translation" => "soft_validations.monthly_charges_over_soft_max.hint_text" })
expect(page.informative_text).to eq({ "arguments" => [], "translation" => "forms.2024.sales.soft_validations.monthly_charges_value_check.informative_text" })
end
it "has correct interruption_screen_question_ids" do

7
spec/models/form/sales/pages/no_address_found_spec.rb

@ -5,8 +5,9 @@ RSpec.describe Form::Sales::Pages::NoAddressFound, type: :model do
let(:page_id) { nil }
let(:page_definition) { nil }
let(:subsection) { instance_double(Form::Subsection) }
let(:log) { create(:sales_log) }
let(:form) { instance_double(Form, start_date: Time.zone.local(2024, 4, 1)) }
let(:subsection) { instance_double(Form::Subsection, form:) }
it "has correct subsection" do
expect(page.subsection).to eq(subsection)
@ -31,11 +32,11 @@ RSpec.describe Form::Sales::Pages::NoAddressFound, type: :model do
end
it "has the correct title_text" do
expect(page.title_text).to eq({ "arguments" => [], "translation" => "soft_validations.no_address_found.title_text" })
expect(page.title_text).to eq({ "arguments" => [], "translation" => "forms.2024.sales.soft_validations.address_search_value_check.title_text" })
end
it "has the correct informative_text" do
expect(page.informative_text).to eq({ "arguments" => [], "translation" => "soft_validations.no_address_found.informative_text" })
expect(page.informative_text).to eq({ "arguments" => [], "translation" => "forms.2024.sales.soft_validations.address_search_value_check.informative_text" })
end
it "has the correct interruption_screen_question_ids" do

7
spec/models/form/sales/pages/percentage_discount_value_check_spec.rb

@ -5,7 +5,8 @@ RSpec.describe Form::Sales::Pages::PercentageDiscountValueCheck, type: :model do
let(:page_id) { "percentage_discount_value_check" }
let(:page_definition) { nil }
let(:subsection) { instance_double(Form::Subsection) }
let(:form) { instance_double(Form, start_date: Time.zone.local(2024, 4, 1)) }
let(:subsection) { instance_double(Form::Subsection, form:) }
it "has correct subsection" do
expect(page.subsection).to eq(subsection)
@ -21,14 +22,14 @@ RSpec.describe Form::Sales::Pages::PercentageDiscountValueCheck, type: :model do
it "has the correct title_text" do
expect(page.title_text).to eq({
"translation" => "soft_validations.percentage_discount_value.title_text",
"translation" => "forms.2024.sales.soft_validations.percentage_discount_value_check.title_text",
"arguments" => [{ "key" => "discount", "label" => true, "i18n_template" => "discount" }],
})
end
it "has the correct informative_text" do
expect(page.informative_text).to eq({
"translation" => "soft_validations.percentage_discount_value.hint_text",
"translation" => "forms.2024.sales.soft_validations.percentage_discount_value_check.informative_text",
"arguments" => [],
})
end

29
spec/models/form/sales/pages/postcode_spec.rb

@ -1,29 +0,0 @@
require "rails_helper"
RSpec.describe Form::Sales::Pages::Postcode, 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[pcodenk postcode_full])
end
it "has the correct id" do
expect(page.id).to eq("property_postcode")
end
it "has the correct description" do
expect(page.description).to be_nil
end
it "has correct depends_on" do
expect(page.depends_on).to be_nil
end
end

13
spec/models/form/sales/pages/property_local_authority_spec.rb

@ -18,19 +18,6 @@ RSpec.describe Form::Sales::Pages::PropertyLocalAuthority, type: :model do
end
describe "has correct questions" do
context "when 2022" do
let(:start_date) { Time.utc(2022, 2, 8) }
it "has correct questions" do
expect(page.questions.map(&:id)).to eq(
%w[
la_known
la
],
)
end
end
context "when 2023" do
let(:start_date) { Time.utc(2023, 2, 8) }

47
spec/models/form/sales/questions/postcode_known_spec.rb

@ -1,47 +0,0 @@
require "rails_helper"
RSpec.describe Form::Sales::Questions::PostcodeKnown, type: :model do
subject(:question) { described_class.new(question_id, question_definition, page) }
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("pcodenk")
end
it "has the correct type" do
expect(question.type).to eq("radio")
end
it "is not marked as derived" do
expect(question.derived?(nil)).to be false
end
it "has the correct answer_options" do
expect(question.answer_options).to eq({
"0" => { "value" => "Yes" },
"1" => { "value" => "No" },
})
end
it "has correct conditional for" do
expect(question.conditional_for).to eq({
"postcode_full" => [0],
})
end
it "has the correct hidden_in_check_answers" do
expect(question.hidden_in_check_answers).to eq({
"depends_on" => [
{ "pcodenk" => 0 },
{ "pcodenk" => 1 },
],
})
end
end

46
spec/models/form/sales/questions/postcode_spec.rb

@ -1,46 +0,0 @@
require "rails_helper"
RSpec.describe Form::Sales::Questions::Postcode, type: :model do
subject(:question) { described_class.new(question_id, question_definition, page) }
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("postcode_full")
end
it "has the correct type" do
expect(question.type).to eq("text")
end
it "is not marked as derived" do
expect(question.derived?(nil)).to be false
end
it "has the correct width" do
expect(question.width).to eq(5)
end
it "has the correct inferred_answers" do
expect(question.inferred_answers).to eq({
"la" => {
"is_la_inferred" => true,
},
})
end
it "has the correct inferred_check_answers_value" do
expect(question.inferred_check_answers_value).to eq([{
"condition" => {
"pcodenk" => 1,
},
"value" => "Not known",
}])
end
end

6
spec/models/form/sales/questions/uprn_confirmation_spec.rb

@ -1,11 +1,13 @@
require "rails_helper"
RSpec.describe Form::Sales::Questions::UprnConfirmation, type: :model do
include FormattingHelper
subject(:question) { described_class.new(question_id, question_definition, page) }
let(:question_id) { nil }
let(:question_definition) { nil }
let(:page) { instance_double(Form::Page) }
let(:page) { instance_double(Form::Page, subsection: instance_double(Form::Subsection, form: instance_double(Form, start_date: Time.zone.local(2023, 4, 4), type: "sales"), id: "property_information")) }
it "has correct page" do
expect(question.page).to eq(page)
@ -24,7 +26,7 @@ RSpec.describe Form::Sales::Questions::UprnConfirmation, type: :model do
end
it "has the correct unanswered_error_message" do
expect(question.unanswered_error_message).to eq("You must answer is this the right address?")
expect(question.unanswered_error_message).to eq("You must answer #{format_ending(I18n.t('forms.2023.sales.property_information.uprn_confirmed.check_answer_label'))}")
end
describe "notification_banner" do

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

@ -1,6 +1,8 @@
require "rails_helper"
RSpec.describe Form::Sales::Questions::UprnKnown, type: :model do
include FormattingHelper
subject(:question) { described_class.new(question_id, question_definition, page) }
let(:question_id) { nil }
@ -35,7 +37,7 @@ RSpec.describe Form::Sales::Questions::UprnKnown, type: :model do
end
it "has the correct unanswered_error_message" do
expect(question.unanswered_error_message).to eq("You must answer UPRN known?")
expect(question.unanswered_error_message).to eq("You must answer #{format_ending(I18n.t('forms.2023.sales.property_information.uprn.uprn_known.check_answer_label'))}")
end
it "has the correct hidden_in_check_answers" do

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

@ -17,30 +17,6 @@ RSpec.describe Form::Sales::Subsections::PropertyInformation, type: :model do
allow(form).to receive(:start_year_after_2024?).and_return(false)
end
context "when 2022" do
let(:start_date) { Time.utc(2022, 2, 8) }
it "has correct pages" do
expect(property_information.pages.compact.map(&:id)).to eq(
%w[
property_number_of_bedrooms
about_price_bedrooms_value_check
property_unit_type
monthly_charges_property_type_value_check
percentage_discount_proptype_value_check
property_building_type
property_postcode
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
property_wheelchair_accessible
],
)
end
end
context "when 2023" do
let(:start_date) { Time.utc(2023, 2, 8) }

Loading…
Cancel
Save