Browse Source

Merge branch 'main' into BuGuidanceNoYear

pull/2695/head
Rachael Booth 2 years ago committed by GitHub
parent
commit
d6b233883d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 2
      Gemfile
  2. 128
      Gemfile.lock
  3. 4
      app/controllers/organisation_relationships_controller.rb
  4. 10
      app/models/form/page.rb
  5. 30
      app/models/form/question.rb
  6. 1
      app/models/form/sales/pages/buyer_interview.rb
  7. 6
      app/models/form/sales/pages/discounted_ownership_type.rb
  8. 6
      app/models/form/sales/pages/outright_ownership_type.rb
  9. 2
      app/models/form/sales/pages/privacy_notice.rb
  10. 6
      app/models/form/sales/pages/shared_ownership_type.rb
  11. 2
      app/models/form/sales/questions/buyer_company.rb
  12. 4
      app/models/form/sales/questions/buyer_interview.rb
  13. 2
      app/models/form/sales/questions/buyer_live.rb
  14. 2
      app/models/form/sales/questions/created_by_id.rb
  15. 3
      app/models/form/sales/questions/discounted_ownership_type.rb
  16. 8
      app/models/form/sales/questions/joint_purchase.rb
  17. 2
      app/models/form/sales/questions/managing_organisation.rb
  18. 10
      app/models/form/sales/questions/number_joint_buyers.rb
  19. 3
      app/models/form/sales/questions/other_ownership_type.rb
  20. 3
      app/models/form/sales/questions/outright_ownership_type.rb
  21. 2
      app/models/form/sales/questions/ownership_scheme.rb
  22. 2
      app/models/form/sales/questions/owning_organisation_id.rb
  23. 3
      app/models/form/sales/questions/privacy_notice.rb
  24. 3
      app/models/form/sales/questions/purchaser_code.rb
  25. 2
      app/models/form/sales/questions/sale_date.rb
  26. 11
      app/models/form/sales/questions/shared_ownership_type.rb
  27. 4
      app/models/organisation.rb
  28. 34
      app/models/validations/sales/setup_validations.rb
  29. 3
      app/policies/user_policy.rb
  30. 6
      app/services/address_client.rb
  31. 2
      app/views/form/_date_question.html.erb
  32. 2
      app/views/users/edit.html.erb
  33. 9
      config/locales/en.yml
  34. 110
      config/locales/forms/2023/sales/setup.en.yml
  35. 110
      config/locales/forms/2024/sales/setup.en.yml
  36. 25
      config/locales/validations/sales/setup.en.yml
  37. 37
      spec/features/organisation_relationships.html.erb_spec.rb
  38. 4
      spec/models/form/lettings/pages/address_fallback_spec.rb
  39. 4
      spec/models/form/lettings/pages/address_matcher_spec.rb
  40. 4
      spec/models/form/lettings/pages/address_spec.rb
  41. 4
      spec/models/form/lettings/pages/care_home_charges_value_check_spec.rb
  42. 4
      spec/models/form/lettings/pages/created_by_spec.rb
  43. 4
      spec/models/form/lettings/pages/females_in_soft_age_range_in_pregnant_household_person_age_value_check_spec.rb
  44. 4
      spec/models/form/lettings/pages/females_in_soft_age_range_in_pregnant_household_person_value_check_spec.rb
  45. 4
      spec/models/form/lettings/pages/first_time_property_let_as_social_housing_spec.rb
  46. 4
      spec/models/form/lettings/pages/lead_tenant_ethnic_background_white_spec.rb
  47. 4
      spec/models/form/lettings/pages/location_spec.rb
  48. 4
      spec/models/form/lettings/pages/managing_organisation_spec.rb
  49. 4
      spec/models/form/lettings/pages/max_rent_value_check_spec.rb
  50. 4
      spec/models/form/lettings/pages/min_rent_value_check_spec.rb
  51. 4
      spec/models/form/lettings/pages/multiple_partners_value_check_spec.rb
  52. 4
      spec/models/form/lettings/pages/needs_type_spec.rb
  53. 4
      spec/models/form/lettings/pages/net_income_value_check_spec.rb
  54. 4
      spec/models/form/lettings/pages/no_address_found_spec.rb
  55. 4
      spec/models/form/lettings/pages/no_females_pregnant_household_person_age_value_check_spec.rb
  56. 4
      spec/models/form/lettings/pages/no_females_pregnant_household_person_value_check_spec.rb
  57. 4
      spec/models/form/lettings/pages/partner_under16_value_check_spec.rb
  58. 4
      spec/models/form/lettings/pages/person_age_spec.rb
  59. 4
      spec/models/form/lettings/pages/person_gender_identity_spec.rb
  60. 4
      spec/models/form/lettings/pages/person_known_spec.rb
  61. 4
      spec/models/form/lettings/pages/person_over_retirement_value_check_spec.rb
  62. 4
      spec/models/form/lettings/pages/person_relationship_to_lead_spec.rb
  63. 4
      spec/models/form/lettings/pages/person_under_retirement_value_check_spec.rb
  64. 4
      spec/models/form/lettings/pages/person_working_situation_spec.rb
  65. 4
      spec/models/form/lettings/pages/previous_housing_situation_renewal_spec.rb
  66. 4
      spec/models/form/lettings/pages/previous_housing_situation_spec.rb
  67. 4
      spec/models/form/lettings/pages/previous_local_authority_spec.rb
  68. 4
      spec/models/form/lettings/pages/previous_postcode_spec.rb
  69. 4
      spec/models/form/lettings/pages/property_local_authority_spec.rb
  70. 4
      spec/models/form/lettings/pages/property_number_of_times_relet_spec.rb
  71. 4
      spec/models/form/lettings/pages/property_reference_spec.rb
  72. 4
      spec/models/form/lettings/pages/property_wheelchair_accessible_spec.rb
  73. 4
      spec/models/form/lettings/pages/renewal_spec.rb
  74. 4
      spec/models/form/lettings/pages/rent_type_spec.rb
  75. 4
      spec/models/form/lettings/pages/scheme_spec.rb
  76. 4
      spec/models/form/lettings/pages/sheltered_accommodation_spec.rb
  77. 4
      spec/models/form/lettings/pages/starter_tenancy_type_spec.rb
  78. 4
      spec/models/form/lettings/pages/stock_owner_spec.rb
  79. 4
      spec/models/form/lettings/pages/tenancy_length_periodic_spec.rb
  80. 4
      spec/models/form/lettings/pages/tenancy_length_spec.rb
  81. 4
      spec/models/form/lettings/pages/tenancy_start_date_spec.rb
  82. 4
      spec/models/form/lettings/pages/tenancy_type_spec.rb
  83. 4
      spec/models/form/lettings/pages/tenant_code_spec.rb
  84. 4
      spec/models/form/lettings/pages/uprn_confirmation_spec.rb
  85. 4
      spec/models/form/lettings/pages/uprn_selection_spec.rb
  86. 4
      spec/models/form/lettings/pages/uprn_spec.rb
  87. 4
      spec/models/form/lettings/pages/void_date_spec.rb
  88. 12
      spec/models/form/lettings/questions/address_line1_for_address_matcher_spec.rb
  89. 12
      spec/models/form/lettings/questions/address_line1_spec.rb
  90. 12
      spec/models/form/lettings/questions/address_line2_spec.rb
  91. 24
      spec/models/form/lettings/questions/age1_known_spec.rb
  92. 16
      spec/models/form/lettings/questions/age_known_spec.rb
  93. 26
      spec/models/form/lettings/questions/age_spec.rb
  94. 22
      spec/models/form/lettings/questions/beds_spec.rb
  95. 12
      spec/models/form/lettings/questions/care_home_charges_value_check_spec.rb
  96. 12
      spec/models/form/lettings/questions/county_spec.rb
  97. 12
      spec/models/form/lettings/questions/created_by_id_spec.rb
  98. 12
      spec/models/form/lettings/questions/declaration_spec.rb
  99. 20
      spec/models/form/lettings/questions/details_known_spec.rb
  100. 16
      spec/models/form/lettings/questions/ethnic_white_spec.rb
  101. Some files were not shown because too many files have changed in this diff Show More

2
Gemfile

@ -6,7 +6,7 @@ git_source(:github) { |repo| "https://github.com/#{repo}.git" }
ruby "3.1.4" ruby "3.1.4"
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails', branch: 'main' # Bundle edge Rails instead: gem 'rails', github: 'rails/rails', branch: 'main'
gem "rails", "~> 7.0.8.3" gem "rails", "~> 7.0.8.5"
# Use postgresql as the database for Active Record # Use postgresql as the database for Active Record
gem "pg", "~> 1.1" gem "pg", "~> 1.1"
# Use Puma as the app server # Use Puma as the app server

128
Gemfile.lock

@ -1,71 +1,71 @@
GEM GEM
remote: https://rubygems.org/ remote: https://rubygems.org/
specs: specs:
actioncable (7.0.8.4) actioncable (7.0.8.5)
actionpack (= 7.0.8.4) actionpack (= 7.0.8.5)
activesupport (= 7.0.8.4) activesupport (= 7.0.8.5)
nio4r (~> 2.0) nio4r (~> 2.0)
websocket-driver (>= 0.6.1) websocket-driver (>= 0.6.1)
actionmailbox (7.0.8.4) actionmailbox (7.0.8.5)
actionpack (= 7.0.8.4) actionpack (= 7.0.8.5)
activejob (= 7.0.8.4) activejob (= 7.0.8.5)
activerecord (= 7.0.8.4) activerecord (= 7.0.8.5)
activestorage (= 7.0.8.4) activestorage (= 7.0.8.5)
activesupport (= 7.0.8.4) activesupport (= 7.0.8.5)
mail (>= 2.7.1) mail (>= 2.7.1)
net-imap net-imap
net-pop net-pop
net-smtp net-smtp
actionmailer (7.0.8.4) actionmailer (7.0.8.5)
actionpack (= 7.0.8.4) actionpack (= 7.0.8.5)
actionview (= 7.0.8.4) actionview (= 7.0.8.5)
activejob (= 7.0.8.4) activejob (= 7.0.8.5)
activesupport (= 7.0.8.4) activesupport (= 7.0.8.5)
mail (~> 2.5, >= 2.5.4) mail (~> 2.5, >= 2.5.4)
net-imap net-imap
net-pop net-pop
net-smtp net-smtp
rails-dom-testing (~> 2.0) rails-dom-testing (~> 2.0)
actionpack (7.0.8.4) actionpack (7.0.8.5)
actionview (= 7.0.8.4) actionview (= 7.0.8.5)
activesupport (= 7.0.8.4) activesupport (= 7.0.8.5)
rack (~> 2.0, >= 2.2.4) rack (~> 2.0, >= 2.2.4)
rack-test (>= 0.6.3) rack-test (>= 0.6.3)
rails-dom-testing (~> 2.0) rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.2.0) rails-html-sanitizer (~> 1.0, >= 1.2.0)
actiontext (7.0.8.4) actiontext (7.0.8.5)
actionpack (= 7.0.8.4) actionpack (= 7.0.8.5)
activerecord (= 7.0.8.4) activerecord (= 7.0.8.5)
activestorage (= 7.0.8.4) activestorage (= 7.0.8.5)
activesupport (= 7.0.8.4) activesupport (= 7.0.8.5)
globalid (>= 0.6.0) globalid (>= 0.6.0)
nokogiri (>= 1.8.5) nokogiri (>= 1.8.5)
actionview (7.0.8.4) actionview (7.0.8.5)
activesupport (= 7.0.8.4) activesupport (= 7.0.8.5)
builder (~> 3.1) builder (~> 3.1)
erubi (~> 1.4) erubi (~> 1.4)
rails-dom-testing (~> 2.0) rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.1, >= 1.2.0) rails-html-sanitizer (~> 1.1, >= 1.2.0)
activejob (7.0.8.4) activejob (7.0.8.5)
activesupport (= 7.0.8.4) activesupport (= 7.0.8.5)
globalid (>= 0.3.6) globalid (>= 0.3.6)
activemodel (7.0.8.4) activemodel (7.0.8.5)
activesupport (= 7.0.8.4) activesupport (= 7.0.8.5)
activemodel-serializers-xml (1.0.2) activemodel-serializers-xml (1.0.2)
activemodel (> 5.x) activemodel (> 5.x)
activesupport (> 5.x) activesupport (> 5.x)
builder (~> 3.1) builder (~> 3.1)
activerecord (7.0.8.4) activerecord (7.0.8.5)
activemodel (= 7.0.8.4) activemodel (= 7.0.8.5)
activesupport (= 7.0.8.4) activesupport (= 7.0.8.5)
activestorage (7.0.8.4) activestorage (7.0.8.5)
actionpack (= 7.0.8.4) actionpack (= 7.0.8.5)
activejob (= 7.0.8.4) activejob (= 7.0.8.5)
activerecord (= 7.0.8.4) activerecord (= 7.0.8.5)
activesupport (= 7.0.8.4) activesupport (= 7.0.8.5)
marcel (~> 1.0) marcel (~> 1.0)
mini_mime (>= 1.1.0) mini_mime (>= 1.1.0)
activesupport (7.0.8.4) activesupport (7.0.8.5)
concurrent-ruby (~> 1.0, >= 1.0.2) concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (>= 1.6, < 2) i18n (>= 1.6, < 2)
minitest (>= 5.1) minitest (>= 5.1)
@ -218,7 +218,7 @@ GEM
hashdiff (1.1.0) hashdiff (1.1.0)
html-attributes-utils (1.0.2) html-attributes-utils (1.0.2)
activesupport (>= 6.1.4.4) activesupport (>= 6.1.4.4)
i18n (1.14.5) i18n (1.14.6)
concurrent-ruby (~> 1.0) concurrent-ruby (~> 1.0)
ice_nine (0.11.2) ice_nine (0.11.2)
iniparse (1.5.0) iniparse (1.5.0)
@ -258,13 +258,13 @@ GEM
matrix (0.4.2) matrix (0.4.2)
method_source (1.1.0) method_source (1.1.0)
mini_mime (1.1.5) mini_mime (1.1.5)
minitest (5.24.1) minitest (5.25.1)
msgpack (1.7.2) msgpack (1.7.2)
multipart-post (2.4.1) multipart-post (2.4.1)
nested_form (0.3.2) nested_form (0.3.2)
net-http (0.4.1) net-http (0.4.1)
uri uri
net-imap (0.4.14) net-imap (0.4.17)
date date
net-protocol net-protocol
net-pop (0.1.2) net-pop (0.1.2)
@ -274,11 +274,11 @@ GEM
net-smtp (0.5.0) net-smtp (0.5.0)
net-protocol net-protocol
nio4r (2.7.3) nio4r (2.7.3)
nokogiri (1.16.6-arm64-darwin) nokogiri (1.16.7-arm64-darwin)
racc (~> 1.4) racc (~> 1.4)
nokogiri (1.16.6-x86_64-darwin) nokogiri (1.16.7-x86_64-darwin)
racc (~> 1.4) racc (~> 1.4)
nokogiri (1.16.6-x86_64-linux) nokogiri (1.16.7-x86_64-linux)
racc (~> 1.4) racc (~> 1.4)
notifications-ruby-client (6.0.0) notifications-ruby-client (6.0.0)
jwt (>= 1.5, < 3) jwt (>= 1.5, < 3)
@ -319,28 +319,28 @@ GEM
pundit (2.3.1) pundit (2.3.1)
activesupport (>= 3.0.0) activesupport (>= 3.0.0)
raabro (1.4.0) raabro (1.4.0)
racc (1.8.0) racc (1.8.1)
rack (2.2.9) rack (2.2.10)
rack-attack (6.7.0) rack-attack (6.7.0)
rack (>= 1.0, < 4) rack (>= 1.0, < 4)
rack-mini-profiler (2.3.4) rack-mini-profiler (2.3.4)
rack (>= 1.2.0) rack (>= 1.2.0)
rack-test (2.1.0) rack-test (2.1.0)
rack (>= 1.3) rack (>= 1.3)
rails (7.0.8.4) rails (7.0.8.5)
actioncable (= 7.0.8.4) actioncable (= 7.0.8.5)
actionmailbox (= 7.0.8.4) actionmailbox (= 7.0.8.5)
actionmailer (= 7.0.8.4) actionmailer (= 7.0.8.5)
actionpack (= 7.0.8.4) actionpack (= 7.0.8.5)
actiontext (= 7.0.8.4) actiontext (= 7.0.8.5)
actionview (= 7.0.8.4) actionview (= 7.0.8.5)
activejob (= 7.0.8.4) activejob (= 7.0.8.5)
activemodel (= 7.0.8.4) activemodel (= 7.0.8.5)
activerecord (= 7.0.8.4) activerecord (= 7.0.8.5)
activestorage (= 7.0.8.4) activestorage (= 7.0.8.5)
activesupport (= 7.0.8.4) activesupport (= 7.0.8.5)
bundler (>= 1.15.0) bundler (>= 1.15.0)
railties (= 7.0.8.4) railties (= 7.0.8.5)
rails-dom-testing (2.2.0) rails-dom-testing (2.2.0)
activesupport (>= 5.0.0) activesupport (>= 5.0.0)
minitest minitest
@ -354,9 +354,9 @@ GEM
nested_form (~> 0.3) nested_form (~> 0.3)
rails (>= 6.0, < 8) rails (>= 6.0, < 8)
turbo-rails (~> 1.0) turbo-rails (~> 1.0)
railties (7.0.8.4) railties (7.0.8.5)
actionpack (= 7.0.8.4) actionpack (= 7.0.8.5)
activesupport (= 7.0.8.4) activesupport (= 7.0.8.5)
method_source method_source
rake (>= 12.2) rake (>= 12.2)
thor (~> 1.0) thor (~> 1.0)
@ -464,7 +464,7 @@ GEM
stimulus-rails (1.3.3) stimulus-rails (1.3.3)
railties (>= 6.0.0) railties (>= 6.0.0)
strscan (3.1.0) strscan (3.1.0)
thor (1.3.1) thor (1.3.2)
thread_safe (0.3.6) thread_safe (0.3.6)
timecop (0.9.8) timecop (0.9.8)
timeout (0.4.1) timeout (0.4.1)
@ -504,7 +504,7 @@ GEM
websocket-extensions (0.1.5) websocket-extensions (0.1.5)
xpath (3.2.0) xpath (3.2.0)
nokogiri (~> 1.8) nokogiri (~> 1.8)
zeitwerk (2.6.16) zeitwerk (2.6.18)
PLATFORMS PLATFORMS
arm64-darwin-21 arm64-darwin-21
@ -555,7 +555,7 @@ DEPENDENCIES
rack (>= 2.2.6.3) rack (>= 2.2.6.3)
rack-attack rack-attack
rack-mini-profiler (~> 2.0) rack-mini-profiler (~> 2.0)
rails (~> 7.0.8.3) rails (~> 7.0.8.5)
rails_admin (~> 3.1) rails_admin (~> 3.1)
redcarpet (~> 3.6) redcarpet (~> 3.6)
redis (~> 4.8) redis (~> 4.8)

4
app/controllers/organisation_relationships_controller.rb

@ -14,7 +14,7 @@ class OrganisationRelationshipsController < ApplicationController
] ]
def stock_owners def stock_owners
stock_owners = organisation.stock_owners.filter_by_active stock_owners = organisation.stock_owners.filter_by_active.order("LOWER(name)")
unpaginated_filtered_stock_owners = filtered_collection(stock_owners, search_term) unpaginated_filtered_stock_owners = filtered_collection(stock_owners, search_term)
@pagy, @stock_owners = pagy(unpaginated_filtered_stock_owners) @pagy, @stock_owners = pagy(unpaginated_filtered_stock_owners)
@ -23,7 +23,7 @@ class OrganisationRelationshipsController < ApplicationController
end end
def managing_agents def managing_agents
managing_agents = organisation.managing_agents.filter_by_active managing_agents = organisation.managing_agents.filter_by_active.order("LOWER(name)")
unpaginated_filtered_managing_agents = filtered_collection(managing_agents, search_term) unpaginated_filtered_managing_agents = filtered_collection(managing_agents, search_term)
@pagy, @managing_agents = pagy(unpaginated_filtered_managing_agents) @pagy, @managing_agents = pagy(unpaginated_filtered_managing_agents)

10
app/models/form/page.rb

@ -1,5 +1,5 @@
class Form::Page class Form::Page
attr_accessor :id, :header, :header_partial, :description, :questions, :depends_on, :title_text, attr_accessor :id, :header_partial, :description, :questions, :depends_on, :title_text,
:informative_text, :subsection, :hide_subsection_label, :next_unresolved_page_id, :informative_text, :subsection, :hide_subsection_label, :next_unresolved_page_id,
:skip_text, :interruption_screen_question_ids, :submit_text :skip_text, :interruption_screen_question_ids, :submit_text
@ -24,6 +24,14 @@ class Form::Page
delegate :form, to: :subsection delegate :form, to: :subsection
def copy_key
@copy_key ||= "#{form.type}.#{subsection.id}.#{questions[0].id}"
end
def header
@header ||= I18n.t("forms.#{form.start_date.year}.#{copy_key}.page_header", default: "")
end
def routed_to?(log, _current_user) def routed_to?(log, _current_user)
return true unless depends_on || subsection.depends_on return true unless depends_on || subsection.depends_on

30
app/models/form/question.rb

@ -1,9 +1,9 @@
class Form::Question class Form::Question
include FormattingHelper include FormattingHelper
attr_accessor :id, :header, :hint_text, :description, :questions, :disable_clearing_if_not_routed_or_dynamic_answer_options, attr_accessor :id, :description, :questions, :disable_clearing_if_not_routed_or_dynamic_answer_options,
:type, :min, :max, :step, :width, :fields_to_add, :result_field, :type, :min, :max, :step, :width, :fields_to_add, :result_field,
:conditional_for, :readonly, :answer_options, :page, :check_answer_label, :conditional_for, :readonly, :answer_options, :page,
:inferred_answers, :hidden_in_check_answers, :inferred_check_answers_value, :inferred_answers, :hidden_in_check_answers, :inferred_check_answers_value,
:top_guidance_partial, :bottom_guidance_partial, :prefix, :suffix, :top_guidance_partial, :bottom_guidance_partial, :prefix, :suffix,
:requires_js, :fields_added, :derived, :check_answers_card_number, :requires_js, :fields_added, :derived, :check_answers_card_number,
@ -50,6 +50,22 @@ class Form::Question
delegate :subsection, to: :page delegate :subsection, to: :page
delegate :form, to: :subsection delegate :form, to: :subsection
def copy_key
@copy_key ||= "#{form.type}.#{subsection.id}.#{id}"
end
def check_answer_label
@check_answer_label ||= I18n.t("forms.#{form.start_date.year}.#{copy_key}.check_answer_label", default: "")
end
def header
@header ||= I18n.t("forms.#{form.start_date.year}.#{copy_key}.question_text", default: "")
end
def hint_text
@hint_text ||= I18n.t("forms.#{form.start_date.year}.#{copy_key}.hint_text", default: "")
end
def answer_label(log, user = nil) def answer_label(log, user = nil)
return checkbox_answer_label(log) if type == "checkbox" return checkbox_answer_label(log) if type == "checkbox"
return log[id]&.to_formatted_s(:govuk_date).to_s if type == "date" return log[id]&.to_formatted_s(:govuk_date).to_s if type == "date"
@ -206,7 +222,15 @@ class Form::Question
end end
def error_display_label def error_display_label
label = error_label || check_answer_label || header || id.humanize label = if error_label.present?
error_label
elsif check_answer_label.present?
check_answer_label
elsif header.present?
header
else
id.humanize
end
format_ending(label) format_ending(label)
end end

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

@ -2,6 +2,7 @@ class Form::Sales::Pages::BuyerInterview < ::Form::Page
def initialize(id, hsh, subsection, joint_purchase:) def initialize(id, hsh, subsection, joint_purchase:)
super(id, hsh, subsection) super(id, hsh, subsection)
@joint_purchase = joint_purchase @joint_purchase = joint_purchase
@copy_key = "sales.setup.noint.#{joint_purchase ? 'joint_purchase' : 'not_joint_purchase'}"
end end
def questions def questions

6
app/models/form/sales/pages/discounted_ownership_type.rb

@ -2,7 +2,7 @@ class Form::Sales::Pages::DiscountedOwnershipType < ::Form::Page
def initialize(id, hsh, subsection) def initialize(id, hsh, subsection)
super super
@id = "discounted_ownership_type" @id = "discounted_ownership_type"
@header = header @copy_key = "sales.setup.type.discounted_ownership"
@depends_on = [{ @depends_on = [{
"ownershipsch" => 2, "ownershipsch" => 2,
}] }]
@ -13,8 +13,4 @@ class Form::Sales::Pages::DiscountedOwnershipType < ::Form::Page
Form::Sales::Questions::DiscountedOwnershipType.new(nil, nil, self), Form::Sales::Questions::DiscountedOwnershipType.new(nil, nil, self),
] ]
end end
def header
"Type of discounted ownership sale" if form.start_date.year >= 2023
end
end end

6
app/models/form/sales/pages/outright_ownership_type.rb

@ -2,7 +2,7 @@ class Form::Sales::Pages::OutrightOwnershipType < ::Form::Page
def initialize(id, hsh, subsection) def initialize(id, hsh, subsection)
super super
@id = "outright_ownership_type" @id = "outright_ownership_type"
@header = header @copy_key = "sales.setup.type.outright_ownership"
@depends_on = [{ @depends_on = [{
"ownershipsch" => 3, "ownershipsch" => 3,
}] }]
@ -14,8 +14,4 @@ class Form::Sales::Pages::OutrightOwnershipType < ::Form::Page
Form::Sales::Questions::OtherOwnershipType.new(nil, nil, self), Form::Sales::Questions::OtherOwnershipType.new(nil, nil, self),
] ]
end end
def header
"Type of outright sale" if form.start_date.year >= 2023
end
end end

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

@ -1,7 +1,7 @@
class Form::Sales::Pages::PrivacyNotice < ::Form::Page class Form::Sales::Pages::PrivacyNotice < ::Form::Page
def initialize(id, hsh, subsection, joint_purchase:) def initialize(id, hsh, subsection, joint_purchase:)
super(id, hsh, subsection) super(id, hsh, subsection)
@header = "Ministry of Housing, Communities and Local Government privacy notice" @copy_key = "sales.setup.privacynotice.#{joint_purchase ? 'joint_purchase' : 'not_joint_purchase'}"
@joint_purchase = joint_purchase @joint_purchase = joint_purchase
end end

6
app/models/form/sales/pages/shared_ownership_type.rb

@ -2,7 +2,7 @@ class Form::Sales::Pages::SharedOwnershipType < ::Form::Page
def initialize(id, hsh, subsection) def initialize(id, hsh, subsection)
super super
@id = "shared_ownership_type" @id = "shared_ownership_type"
@header = header @copy_key = "sales.setup.type.shared_ownership"
@depends_on = [{ @depends_on = [{
"ownershipsch" => 1, "ownershipsch" => 1,
}] }]
@ -13,8 +13,4 @@ class Form::Sales::Pages::SharedOwnershipType < ::Form::Page
Form::Sales::Questions::SharedOwnershipType.new(nil, nil, self), Form::Sales::Questions::SharedOwnershipType.new(nil, nil, self),
] ]
end end
def header
"Type of shared ownership sale" if form.start_date.year >= 2023
end
end end

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

@ -2,8 +2,6 @@ class Form::Sales::Questions::BuyerCompany < ::Form::Question
def initialize(id, hsh, page) def initialize(id, hsh, page)
super super
@id = "companybuy" @id = "companybuy"
@check_answer_label = "Company buyer"
@header = "Is the buyer a company?"
@type = "radio" @type = "radio"
@answer_options = ANSWER_OPTIONS @answer_options = ANSWER_OPTIONS
@question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] @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/buyer_interview.rb

@ -2,10 +2,8 @@ class Form::Sales::Questions::BuyerInterview < ::Form::Question
def initialize(id, hsh, page, joint_purchase:) def initialize(id, hsh, page, joint_purchase:)
super(id, hsh, page) super(id, hsh, page)
@id = "noint" @id = "noint"
@check_answer_label = "#{joint_purchase ? 'Buyers' : 'Buyer'} interviewed in person?" @copy_key = "sales.setup.noint.#{joint_purchase ? 'joint_purchase' : 'not_joint_purchase'}"
@header = "#{joint_purchase ? 'Were the buyers' : 'Was the buyer'} interviewed for any of the answers you will provide on this log?"
@type = "radio" @type = "radio"
@hint_text = "You should still try to answer all questions even if the #{joint_purchase ? 'buyers weren’t' : 'buyer wasn’t'} interviewed in person"
@answer_options = ANSWER_OPTIONS @answer_options = ANSWER_OPTIONS
@question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] @question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max]
end end

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

@ -2,8 +2,6 @@ class Form::Sales::Questions::BuyerLive < ::Form::Question
def initialize(id, hsh, page) def initialize(id, hsh, page)
super super
@id = "buylivein" @id = "buylivein"
@check_answer_label = "Buyers living in property"
@header = form.start_year_after_2024? ? "Will any buyers live in the property?" : "Will the buyers live in the property?"
@type = "radio" @type = "radio"
@answer_options = ANSWER_OPTIONS @answer_options = ANSWER_OPTIONS
@question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] @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/created_by_id.rb

@ -4,8 +4,6 @@ class Form::Sales::Questions::CreatedById < ::Form::Question
def initialize(id, hsh, page) def initialize(id, hsh, page)
super super
@id = "assigned_to_id" @id = "assigned_to_id"
@check_answer_label = "Log owner"
@header = "Which user are you creating this log for?"
@derived = true @derived = true
@type = "select" @type = "select"
end end

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

@ -2,8 +2,7 @@ class Form::Sales::Questions::DiscountedOwnershipType < ::Form::Question
def initialize(id, hsh, page) def initialize(id, hsh, page)
super super
@id = "type" @id = "type"
@check_answer_label = "Type of discounted ownership sale" @copy_key = "sales.setup.type.discounted_ownership"
@header = "What is the type of discounted ownership sale?"
@type = "radio" @type = "radio"
@top_guidance_partial = guidance_partial @top_guidance_partial = guidance_partial
@answer_options = ANSWER_OPTIONS @answer_options = ANSWER_OPTIONS

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

@ -2,8 +2,6 @@ class Form::Sales::Questions::JointPurchase < ::Form::Question
def initialize(id, hsh, page) def initialize(id, hsh, page)
super super
@id = "jointpur" @id = "jointpur"
@check_answer_label = "Joint purchase"
@header = "Is this a joint purchase?"
@type = "radio" @type = "radio"
@answer_options = ANSWER_OPTIONS @answer_options = ANSWER_OPTIONS
@question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] @question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max]
@ -14,11 +12,5 @@ class Form::Sales::Questions::JointPurchase < ::Form::Question
"2" => { "value" => "No" }, "2" => { "value" => "No" },
}.freeze }.freeze
def hint_text
if form.start_year_after_2024?
"This is where two or more people are named as legal owners of the property after the purchase"
end
end
QUESTION_NUMBER_FROM_YEAR = { 2023 => 9, 2024 => 11 }.freeze QUESTION_NUMBER_FROM_YEAR = { 2023 => 9, 2024 => 11 }.freeze
end end

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

@ -2,8 +2,6 @@ class Form::Sales::Questions::ManagingOrganisation < ::Form::Question
def initialize(id, hsh, page) def initialize(id, hsh, page)
super super
@id = "managing_organisation_id" @id = "managing_organisation_id"
@check_answer_label = "Reported by"
@header = "Which organisation is reporting this sale?"
@derived = true @derived = true
@type = "select" @type = "select"
@question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] @question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max]

10
app/models/form/sales/questions/number_joint_buyers.rb

@ -2,8 +2,6 @@ class Form::Sales::Questions::NumberJointBuyers < ::Form::Question
def initialize(id, hsh, page) def initialize(id, hsh, page)
super super
@id = "jointmore" @id = "jointmore"
@check_answer_label = "More than 2 joint buyers"
@header = "Are there more than 2 joint buyers of this property?"
@type = "radio" @type = "radio"
@answer_options = ANSWER_OPTIONS @answer_options = ANSWER_OPTIONS
@question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] @question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max]
@ -15,13 +13,5 @@ class Form::Sales::Questions::NumberJointBuyers < ::Form::Question
"3" => { "value" => "Don’t know" }, "3" => { "value" => "Don’t know" },
}.freeze }.freeze
def hint_text
if form.start_year_after_2024?
nil
else
"You should still try to answer all questions even if the buyers weren’t interviewed in person"
end
end
QUESTION_NUMBER_FROM_YEAR = { 2023 => 10, 2024 => 12 }.freeze QUESTION_NUMBER_FROM_YEAR = { 2023 => 10, 2024 => 12 }.freeze
end end

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

@ -2,8 +2,7 @@ class Form::Sales::Questions::OtherOwnershipType < ::Form::Question
def initialize(id, hsh, page) def initialize(id, hsh, page)
super super
@id = "othtype" @id = "othtype"
@check_answer_label = "Type of other sale" @copy_key = "sales.setup.type.outright_ownership.othtype"
@header = "What type of sale is it?"
@type = "text" @type = "text"
@width = 10 @width = 10
@question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] @question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max]

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

@ -2,8 +2,7 @@ class Form::Sales::Questions::OutrightOwnershipType < ::Form::Question
def initialize(id, hsh, page) def initialize(id, hsh, page)
super super
@id = "type" @id = "type"
@check_answer_label = "Type of outright sale" @copy_key = "sales.setup.type.outright_ownership.type"
@header = "What is the type of outright sale?"
@type = "radio" @type = "radio"
@top_guidance_partial = guidance_partial @top_guidance_partial = guidance_partial
@answer_options = ANSWER_OPTIONS @answer_options = ANSWER_OPTIONS

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

@ -2,8 +2,6 @@ class Form::Sales::Questions::OwnershipScheme < ::Form::Question
def initialize(id, hsh, page) def initialize(id, hsh, page)
super super
@id = "ownershipsch" @id = "ownershipsch"
@check_answer_label = "Purchase made under ownership scheme"
@header = "Was this purchase made through an ownership scheme?"
@type = "radio" @type = "radio"
@question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] @question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max]
end end

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

@ -2,8 +2,6 @@ class Form::Sales::Questions::OwningOrganisationId < ::Form::Question
def initialize(id, hsh, page) def initialize(id, hsh, page)
super super
@id = "owning_organisation_id" @id = "owning_organisation_id"
@check_answer_label = "Owning organisation"
@header = "Which organisation owns this log?"
@derived = true @derived = true
@type = "select" @type = "select"
@question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] @question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max]

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

@ -2,8 +2,7 @@ class Form::Sales::Questions::PrivacyNotice < ::Form::Question
def initialize(id, hsh, page, joint_purchase:) def initialize(id, hsh, page, joint_purchase:)
super(id, hsh, page) super(id, hsh, page)
@id = "privacynotice" @id = "privacynotice"
@check_answer_label = "#{joint_purchase ? 'Buyers have' : 'Buyer has'} seen the privacy notice?" @copy_key = "sales.setup.privacynotice.#{joint_purchase ? 'joint_purchase' : 'not_joint_purchase'}"
@header = "Declaration"
@type = "checkbox" @type = "checkbox"
@question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] @question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max]
@joint_purchase = joint_purchase @joint_purchase = joint_purchase

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

@ -2,9 +2,6 @@ class Form::Sales::Questions::PurchaserCode < ::Form::Question
def initialize(id, hsh, page) def initialize(id, hsh, page)
super super
@id = "purchid" @id = "purchid"
@check_answer_label = "Purchaser code"
@header = "What is the purchaser code?"
@hint_text = "This is how you usually refer to the purchaser on your own systems."
@type = "text" @type = "text"
@width = 10 @width = 10
@question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] @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/sale_date.rb

@ -2,8 +2,6 @@ class Form::Sales::Questions::SaleDate < ::Form::Question
def initialize(id, hsh, page) def initialize(id, hsh, page)
super super
@id = "saledate" @id = "saledate"
@check_answer_label = "Sale completion date"
@header = "What is the sale completion date?"
@type = "date" @type = "date"
@question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] @question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max]
end end

11
app/models/form/sales/questions/shared_ownership_type.rb

@ -2,22 +2,13 @@ class Form::Sales::Questions::SharedOwnershipType < ::Form::Question
def initialize(id, hsh, page) def initialize(id, hsh, page)
super super
@id = "type" @id = "type"
@check_answer_label = "Type of shared ownership sale" @copy_key = "sales.setup.type.shared_ownership"
@header = "What is the type of shared ownership sale?"
@top_guidance_partial = guidance_partial @top_guidance_partial = guidance_partial
@type = "radio" @type = "radio"
@answer_options = answer_options @answer_options = answer_options
@question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] @question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max]
end end
def hint_text
if form.start_year_after_2024?
"When the purchaser buys an initial share of up to 75% of the property value and pays rent to the Private Registered Provider (PRP) on the remaining portion, or a subsequent staircasing transaction"
else
"A shared ownership sale is when the purchaser buys up to 75% of the property value and pays rent to the Private Registered Provider (PRP) on the remaining portion"
end
end
def answer_options def answer_options
if form.start_date.year >= 2023 if form.start_date.year >= 2023
{ {

4
app/models/organisation.rb

@ -115,7 +115,9 @@ class Organisation < ApplicationRecord
mappings = RentPeriod.rent_period_mappings mappings = RentPeriod.rent_period_mappings
return %w[All] if (mappings.keys.map(&:to_i) - rent_period_ids).empty? return %w[All] if (mappings.keys.map(&:to_i) - rent_period_ids).empty?
rent_period_ids.map { |id| mappings.dig(id.to_s, "value") }.compact rent_period_ids.map { |id| mappings.dig(id.to_s, "value") }.compact.uniq.sort_by do |label|
mappings.keys.index { |key| mappings[key]["value"] == label }
end
end end
def data_protection_confirmed? def data_protection_confirmed?

34
app/models/validations/sales/setup_validations.rb

@ -20,7 +20,7 @@ module Validations::Sales::SetupValidations
return unless record.saledate && date_valid?("saledate", record) && !FeatureToggle.allow_future_form_use? return unless record.saledate && date_valid?("saledate", record) && !FeatureToggle.allow_future_form_use?
if record.saledate > Time.zone.today + 14.days if record.saledate > Time.zone.today + 14.days
record.errors.add :saledate, I18n.t("validations.setup.saledate.later_than_14_days_after") record.errors.add :saledate, I18n.t("validations.sales.setup.saledate.not_within.next_two_weeks")
end end
end end
@ -28,16 +28,16 @@ module Validations::Sales::SetupValidations
return unless record.saledate && date_valid?("saledate", record) return unless record.saledate && date_valid?("saledate", record)
if merged_owning_organisation_inactive?(record) if merged_owning_organisation_inactive?(record)
record.errors.add :saledate, I18n.t("validations.setup.saledate.invalid_merged_organisations_saledate", record.errors.add :saledate, I18n.t("validations.sales.setup.saledate.invalid.merged_organisations",
owning_organisation: record.owning_organisation.name, owning_organisation: record.owning_organisation.name,
owning_organisation_merge_date: record.owning_organisation.merge_date.to_formatted_s(:govuk_date), merge_date: record.owning_organisation.merge_date.to_formatted_s(:govuk_date),
owning_absorbing_organisation: record.owning_organisation.absorbing_organisation.name) absorbing_organisation: record.owning_organisation.absorbing_organisation.name)
end end
if absorbing_owning_organisation_inactive?(record) if absorbing_owning_organisation_inactive?(record)
record.errors.add :saledate, I18n.t("validations.setup.saledate.invalid_absorbing_organisations_saledate", record.errors.add :saledate, I18n.t("validations.sales.setup.saledate.invalid.absorbing_organisations",
owning_organisation: record.owning_organisation.name, owning_organisation: record.owning_organisation.name,
owning_organisation_available_from: record.owning_organisation.available_from.to_formatted_s(:govuk_date)) available_from: record.owning_organisation.available_from.to_formatted_s(:govuk_date))
end end
end end
@ -46,14 +46,14 @@ module Validations::Sales::SetupValidations
if record.owning_organisation.present? if record.owning_organisation.present?
if record.owning_organisation&.merge_date.present? && record.owning_organisation.merge_date <= record.saledate if record.owning_organisation&.merge_date.present? && record.owning_organisation.merge_date <= record.saledate
record.errors.add :owning_organisation_id, I18n.t("validations.setup.owning_organisation.inactive_merged_organisation_sales", record.errors.add :owning_organisation_id, I18n.t("validations.sales.setup.owning_organisation.inactive.merged_organisation",
owning_organisation: record.owning_organisation.name, owning_organisation: record.owning_organisation.name,
owning_organisation_merge_date: record.owning_organisation.merge_date.to_formatted_s(:govuk_date), merge_date: record.owning_organisation.merge_date.to_formatted_s(:govuk_date),
owning_absorbing_organisation: record.owning_organisation.absorbing_organisation.name) absorbing_organisation: record.owning_organisation.absorbing_organisation.name)
elsif record.owning_organisation&.absorbed_organisations.present? && record.owning_organisation.available_from.present? && record.owning_organisation.available_from.to_date > record.saledate.to_date elsif record.owning_organisation&.absorbed_organisations.present? && record.owning_organisation.available_from.present? && record.owning_organisation.available_from.to_date > record.saledate.to_date
record.errors.add :owning_organisation_id, I18n.t("validations.setup.owning_organisation.inactive_absorbing_organisation_sales", record.errors.add :owning_organisation_id, I18n.t("validations.sales.setup.owning_organisation.inactive.absorbing_organisation",
owning_organisation: record.owning_organisation.name, owning_organisation: record.owning_organisation.name,
owning_organisation_available_from: record.owning_organisation.available_from.to_formatted_s(:govuk_date)) available_from: record.owning_organisation.available_from.to_formatted_s(:govuk_date))
end end
end end
end end
@ -77,24 +77,22 @@ private
end end
def saledate_validation_error_message def saledate_validation_error_message
current_end_year_long = current_collection_end_date.strftime("#{current_collection_end_date.day.ordinalize} %B %Y")
if FormHandler.instance.sales_in_crossover_period? if FormHandler.instance.sales_in_crossover_period?
I18n.t( I18n.t(
"validations.setup.saledate.previous_and_current_collection_year", "validations.sales.setup.saledate.must_be_within.previous_and_current_collection_year",
previous_start_year_short: previous_collection_start_date.strftime("%y"), previous_start_year_short: previous_collection_start_date.strftime("%y"),
previous_end_year_short: previous_collection_end_date.strftime("%y"), previous_end_year_short: previous_collection_end_date.strftime("%y"),
previous_start_year_long: previous_collection_start_date.strftime("#{previous_collection_start_date.day.ordinalize} %B %Y"), previous_start_year_long: previous_collection_start_date.strftime("#{previous_collection_start_date.day.ordinalize} %B %Y"),
current_end_year_short: current_collection_end_date.strftime("%y"), current_end_year_short: current_collection_end_date.strftime("%y"),
current_end_year_long:, current_end_year_long: current_collection_end_date.strftime("#{current_collection_end_date.day.ordinalize} %B %Y"),
) )
else else
I18n.t( I18n.t(
"validations.setup.saledate.current_collection_year", "validations.sales.setup.saledate.must_be_within.current_collection_year",
current_start_year_short: current_collection_start_date.strftime("%y"), current_start_year_short: current_collection_start_date.strftime("%y"),
current_end_year_short: current_collection_end_date.strftime("%y"),
current_start_year_long: current_collection_start_date.strftime("#{current_collection_start_date.day.ordinalize} %B %Y"), current_start_year_long: current_collection_start_date.strftime("#{current_collection_start_date.day.ordinalize} %B %Y"),
current_end_year_long:, current_end_year_short: current_collection_end_date.strftime("%y"),
current_end_year_long: current_collection_end_date.strftime("#{current_collection_end_date.day.ordinalize} %B %Y"),
) )
end end
end end

3
app/policies/user_policy.rb

@ -17,8 +17,9 @@ class UserPolicy
].each do |method_name| ].each do |method_name|
define_method method_name do define_method method_name do
return true if @current_user.support? return true if @current_user.support?
return true if @current_user.data_coordinator? && @user.active?
@current_user.data_coordinator? && @user.active? Rails.env.staging? && Rails.application.credentials[:staging_role_update_email_allowlist].include?(@current_user.email.split("@").last.downcase)
end end
end end

6
app/services/address_client.rb

@ -20,7 +20,11 @@ class AddressClient
end end
def result def result
@result ||= JSON.parse(response.body)["results"]&.map { |address| address["DPA"] } if response.is_a?(Net::HTTPSuccess)
@result ||= JSON.parse(response.body)["results"]&.map { |address| address["DPA"] }
else
@result = nil
end
end end
private private

2
app/views/form/_date_question.html.erb

@ -3,7 +3,7 @@
<%= f.govuk_date_field question.id.to_sym, <%= f.govuk_date_field question.id.to_sym,
caption: caption(caption_text, page_header, conditional), caption: caption(caption_text, page_header, conditional),
legend: legend(question, page_header, conditional), legend: legend(question, page_header, conditional),
hint: { text: (question.hint_text.nil? ? "" : (question.hint_text.html_safe + "</br></br>".html_safe)) + "For example, #{date_mid_collection_year_formatted(@log.startdate)}" }, hint: { text: (question.hint_text.blank? ? "" : (question.hint_text.html_safe + "</br></br>".html_safe)) + "For example, #{date_mid_collection_year_formatted(@log.startdate)}" },
width: 20, width: 20,
**stimulus_html_attributes(question) do %> **stimulus_html_attributes(question) do %>
<%= govuk_inset_text(text: question.unresolved_hint_text) if question.unresolved_hint_text.present? && @log.unresolved %> <%= govuk_inset_text(text: question.unresolved_hint_text) if question.unresolved_hint_text.present? && @log.unresolved %>

2
app/views/users/edit.html.erb

@ -51,7 +51,7 @@
<% end %> <% end %>
<% end %> <% end %>
<% if current_user.data_coordinator? || current_user.support? %> <% if UserPolicy.new(current_user, @user).edit_roles? %>
<% roles = current_user.assignable_roles.map { |key, _| OpenStruct.new(id: key, name: key.to_s.humanize) } %> <% roles = current_user.assignable_roles.map { |key, _| OpenStruct.new(id: key, name: key.to_s.humanize) } %>
<%= f.govuk_collection_radio_buttons :role, <%= f.govuk_collection_radio_buttons :role,

9
config/locales/en.yml

@ -281,14 +281,7 @@ en:
intermediate_rent_product_name: intermediate_rent_product_name:
blank: "Enter name of other intermediate rent product." blank: "Enter name of other intermediate rent product."
saledate: saledate:
later_than_14_days_after: "Sale completion date must not be later than 14 days from today’s date."
current_collection_year:
"Enter a date within the %{current_start_year_short}/%{current_end_year_short} collection year, which is between %{current_start_year_long} and %{current_end_year_long}."
previous_and_current_collection_year:
"Enter a date within the %{previous_start_year_short}/%{previous_end_year_short} or %{previous_end_year_short}/%{current_end_year_short} collection years, which is between %{previous_start_year_long} and %{current_end_year_long}."
year_not_two_digits: "Sale completion year must be 2 digits." year_not_two_digits: "Sale completion year must be 2 digits."
invalid_merged_organisations_saledate: "Enter a date when the owning organisation was active. %{owning_organisation} became inactive on %{owning_organisation_merge_date} and was replaced by %{owning_absorbing_organisation}."
invalid_absorbing_organisations_saledate: "Enter a date when the owning organisation was active. %{owning_organisation} became active on %{owning_organisation_available_from}."
type: type:
percentage_bought_must_be_at_least_threshold: "The minimum increase in equity while staircasing is %{threshold}% for this shared ownership type." percentage_bought_must_be_at_least_threshold: "The minimum increase in equity while staircasing is %{threshold}% for this shared ownership type."
@ -341,8 +334,6 @@ en:
data_sharing_agreement_not_signed: "The organisation must accept the Data Sharing Agreement before it can be selected as the owning organisation." data_sharing_agreement_not_signed: "The organisation must accept the Data Sharing Agreement before it can be selected as the owning organisation."
inactive_merged_organisation: "The owning organisation must be active on the tenancy start date. %{owning_organisation} became inactive on %{owning_organisation_merge_date} and was replaced by %{owning_absorbing_organisation}." inactive_merged_organisation: "The owning organisation must be active on the tenancy start date. %{owning_organisation} became inactive on %{owning_organisation_merge_date} and was replaced by %{owning_absorbing_organisation}."
inactive_absorbing_organisation: "The owning organisation must be active on the tenancy start date. %{owning_organisation} became active on %{owning_organisation_available_from}." inactive_absorbing_organisation: "The owning organisation must be active on the tenancy start date. %{owning_organisation} became active on %{owning_organisation_available_from}."
inactive_merged_organisation_sales: "The owning organisation must be active on the sale completion date. %{owning_organisation} became inactive on %{owning_organisation_merge_date} and was replaced by %{owning_absorbing_organisation}."
inactive_absorbing_organisation_sales: "The owning organisation must be active on the sale completion date. %{owning_organisation} became active on %{owning_organisation_available_from}."
managing_organisation: managing_organisation:
invalid: "Please select the owning organisation or managing organisation that you belong to." invalid: "Please select the owning organisation or managing organisation that you belong to."
data_sharing_agreement_not_signed: "The organisation must accept the Data Sharing Agreement before it can be selected as the managing organisation." data_sharing_agreement_not_signed: "The organisation must accept the Data Sharing Agreement before it can be selected as the managing organisation."

110
config/locales/forms/2023/sales/setup.en.yml

@ -0,0 +1,110 @@
en:
forms:
2023:
sales:
setup:
owning_organisation_id:
page_header: ""
check_answer_label: "Owning organisation"
hint_text: ""
question_text: "Which organisation owns this log?"
managing_organisation_id:
page_header: ""
check_answer_label: "Reported by"
hint_text: ""
question_text: "Which organisation is reporting this sale?"
assigned_to_id:
page_header: ""
check_answer_label: "Log owner"
hint_text: ""
question_text: "Which user are you creating this log for?"
saledate:
page_header: ""
check_answer_label: "Sale completion date"
hint_text: ""
question_text: "What is the sale completion date?"
purchid:
page_header: ""
check_answer_label: "Purchaser code"
hint_text: "This is how you usually refer to the purchaser on your own systems."
question_text: "What is the purchaser code?"
ownershipsch:
page_header: ""
check_answer_label: "Purchase made under ownership scheme"
hint_text: ""
question_text: "Was this purchase made through an ownership scheme?"
type:
shared_ownership:
page_header: "Type of shared ownership sale"
check_answer_label: "Type of shared ownership sale"
hint_text: "A shared ownership sale is when the purchaser buys up to 75% of the property value and pays rent to the Private Registered Provider (PRP) on the remaining portion"
question_text: "What is the type of shared ownership sale?"
discounted_ownership:
page_header: "Type of discounted ownership sale"
check_answer_label: "Type of discounted ownership sale"
hint_text: ""
question_text: "What is the type of discounted ownership sale?"
outright_ownership:
page_header: "Type of outright sale"
type:
check_answer_label: "Type of outright sale"
hint_text: ""
question_text: "What is the type of outright sale?"
othtype:
check_answer_label: "Type of other sale"
hint_text: ""
question_text: "What type of sale is it?"
companybuy:
page_header: ""
check_answer_label: "Company buyer"
hint_text: ""
question_text: "Is the buyer a company?"
buylivein:
page_header: ""
check_answer_label: "Buyers living in property"
hint_text: ""
question_text: "Will the buyers live in the property?"
jointpur:
page_header: ""
check_answer_label: "Joint purchase"
hint_text: ""
question_text: "Is this a joint purchase?"
jointmore:
page_header: ""
check_answer_label: "More than 2 joint buyers"
hint_text: "You should still try to answer all questions even if the buyers weren’t interviewed in person"
question_text: "Are there more than 2 joint buyers of this property?"
noint:
joint_purchase:
page_header: ""
check_answer_label: "Buyers interviewed in person?"
hint_text: "You should still try to answer all questions even if the buyers weren’t interviewed in person"
question_text: "Were the buyers interviewed for any of the answers you will provide on this log?"
not_joint_purchase:
page_header: ""
check_answer_label: "Buyer interviewed in person?"
hint_text: "You should still try to answer all questions even if the buyer wasn’t interviewed in person"
question_text: "Was the buyer interviewed for any of the answers you will provide on this log?"
privacynotice:
joint_purchase:
page_header: ""
check_answer_label: "Buyers have seen the privacy notice?"
hint_text: ""
question_text: "Declaration"
not_joint_purchase:
page_header: ""
check_answer_label: "Buyer has seen the privacy notice?"
hint_text: ""
question_text: "Declaration"

110
config/locales/forms/2024/sales/setup.en.yml

@ -0,0 +1,110 @@
en:
forms:
2024:
sales:
setup:
owning_organisation_id:
page_header: ""
check_answer_label: "Owning organisation"
hint_text: ""
question_text: "Which organisation owns this log?"
managing_organisation_id:
page_header: ""
check_answer_label: "Reported by"
hint_text: ""
question_text: "Which organisation is reporting this sale?"
assigned_to_id:
page_header: ""
check_answer_label: "Log owner"
hint_text: ""
question_text: "Which user are you creating this log for?"
saledate:
page_header: ""
check_answer_label: "Sale completion date"
hint_text: ""
question_text: "What is the sale completion date?"
purchid:
page_header: ""
check_answer_label: "Purchaser code"
hint_text: "This is how you usually refer to the purchaser on your own systems."
question_text: "What is the purchaser code?"
ownershipsch:
page_header: ""
check_answer_label: "Purchase made under ownership scheme"
hint_text: ""
question_text: "Was this purchase made through an ownership scheme?"
type:
shared_ownership:
page_header: "Type of shared ownership sale"
check_answer_label: "Type of shared ownership sale"
hint_text: "When the purchaser buys an initial share of up to 75% of the property value and pays rent to the Private Registered Provider (PRP) on the remaining portion, or a subsequent staircasing transaction"
question_text: "What is the type of shared ownership sale?"
discounted_ownership:
page_header: "Type of discounted ownership sale"
check_answer_label: "Type of discounted ownership sale"
hint_text: ""
question_text: "What is the type of discounted ownership sale?"
outright_ownership:
page_header: "Type of outright sale"
type:
check_answer_label: "Type of outright sale"
hint_text: ""
question_text: "What is the type of outright sale?"
othtype:
check_answer_label: "Type of other sale"
hint_text: ""
question_text: "What type of sale is it?"
companybuy:
page_header: ""
check_answer_label: "Company buyer"
hint_text: ""
question_text: "Is the buyer a company?"
buylivein:
page_header: ""
check_answer_label: "Buyers living in property"
hint_text: ""
question_text: "Will any buyers live in the property?"
jointpur:
page_header: ""
check_answer_label: "Joint purchase"
hint_text: "This is where two or more people are named as legal owners of the property after the purchase"
question_text: "Is this a joint purchase?"
jointmore:
page_header: ""
check_answer_label: "More than 2 joint buyers"
hint_text: ""
question_text: "Are there more than 2 joint buyers of this property?"
noint:
joint_purchase:
page_header: ""
check_answer_label: "Buyers interviewed in person?"
hint_text: "You should still try to answer all questions even if the buyers weren’t interviewed in person"
question_text: "Were the buyers interviewed for any of the answers you will provide on this log?"
not_joint_purchase:
page_header: ""
check_answer_label: "Buyer interviewed in person?"
hint_text: "You should still try to answer all questions even if the buyer wasn’t interviewed in person"
question_text: "Was the buyer interviewed for any of the answers you will provide on this log?"
privacynotice:
joint_purchase:
page_header: "Ministry of Housing, Communities and Local Government privacy notice"
check_answer_label: "Buyers have seen the privacy notice?"
hint_text: ""
question_text: "Declaration"
not_joint_purchase:
page_header: "Ministry of Housing, Communities and Local Government privacy notice"
check_answer_label: "Buyer has seen the privacy notice?"
hint_text: ""
question_text: "Declaration"

25
config/locales/validations/sales/setup.en.yml

@ -0,0 +1,25 @@
en:
validations:
sales:
setup:
saledate:
not_within:
next_two_weeks: "Sale completion date must not be later than 14 days from today’s date."
must_be_within:
current_collection_year:
"Enter a date within the %{current_start_year_short}/%{current_end_year_short} collection year, which is between %{current_start_year_long} and %{current_end_year_long}."
previous_and_current_collection_year:
"Enter a date within the %{previous_start_year_short}/%{previous_end_year_short} or %{previous_end_year_short}/%{current_end_year_short} collection years, which is between %{previous_start_year_long} and %{current_end_year_long}."
invalid:
merged_organisations:
"Enter a date when the owning organisation was active. %{owning_organisation} became inactive on %{merge_date} and was replaced by %{absorbing_organisation}."
absorbing_organisations:
"Enter a date when the owning organisation was active. %{owning_organisation} became active on %{available_from}."
owning_organisation:
inactive:
merged_organisation:
"The owning organisation must be active on the sale completion date. %{owning_organisation} became inactive on %{merge_date} and was replaced by %{absorbing_organisation}."
absorbing_organisation:
"The owning organisation must be active on the sale completion date. %{owning_organisation} became active on %{available_from}."

37
spec/features/organisation_relationships.html.erb_spec.rb

@ -0,0 +1,37 @@
require "rails_helper"
RSpec.describe "OrganisationRelationships", type: :feature do
context "when viewing the stock owners page" do
let(:user) { create(:user) }
before do
sign_in user
create(:organisation_relationship, parent_organisation: create(:organisation, name: "Zeta"), child_organisation: user.organisation)
create(:organisation_relationship, parent_organisation: create(:organisation, name: "Alpha"), child_organisation: user.organisation)
create(:organisation_relationship, parent_organisation: create(:organisation, name: "Gamma"), child_organisation: user.organisation)
create(:organisation_relationship, parent_organisation: create(:organisation, name: "ABACUS"), child_organisation: user.organisation)
visit("organisations/#{user.organisation.id}/stock-owners")
end
it "displays stock owners in alphabetical order" do
expect(page).to have_content(/ABACUS.*Alpha.*Gamma.*Zeta/m)
end
end
context "when viewing the managing agents page" do
let(:user) { create(:user) }
before do
sign_in user
create(:organisation_relationship, parent_organisation: user.organisation, child_organisation: create(:organisation, name: "Zeta"))
create(:organisation_relationship, parent_organisation: user.organisation, child_organisation: create(:organisation, name: "Alpha"))
create(:organisation_relationship, parent_organisation: user.organisation, child_organisation: create(:organisation, name: "Gamma"))
create(:organisation_relationship, parent_organisation: user.organisation, child_organisation: create(:organisation, name: "ABACUS"))
visit("organisations/#{user.organisation.id}/managing-agents")
end
it "displays stock owners in alphabetical order" do
expect(page).to have_content(/ABACUS.*Alpha.*Gamma.*Zeta/m)
end
end
end

4
spec/models/form/lettings/pages/address_fallback_spec.rb

@ -19,10 +19,6 @@ RSpec.describe Form::Lettings::Pages::AddressFallback, type: :model do
expect(page.id).to eq("address") expect(page.id).to eq("address")
end end
it "has the correct header" do
expect(page.header).to eq("Q12 - What is the property's address?")
end
it "has the correct description" do it "has the correct description" do
expect(page.description).to be_nil expect(page.description).to be_nil
end end

4
spec/models/form/lettings/pages/address_matcher_spec.rb

@ -20,10 +20,6 @@ RSpec.describe Form::Lettings::Pages::AddressMatcher, type: :model do
expect(page.id).to eq("address_matcher") expect(page.id).to eq("address_matcher")
end end
it "has the correct header" do
expect(page.header).to eq("Find an address")
end
it "has the correct description" do it "has the correct description" do
expect(page.description).to be_nil expect(page.description).to be_nil
end end

4
spec/models/form/lettings/pages/address_spec.rb

@ -19,10 +19,6 @@ RSpec.describe Form::Lettings::Pages::Address, type: :model do
expect(page.id).to eq("address") expect(page.id).to eq("address")
end end
it "has the correct header" do
expect(page.header).to eq("Q13 - What is the property's address?")
end
it "has the correct description" do it "has the correct description" do
expect(page.description).to be_nil expect(page.description).to be_nil
end end

4
spec/models/form/lettings/pages/care_home_charges_value_check_spec.rb

@ -10,10 +10,6 @@ RSpec.describe Form::Lettings::Pages::CareHomeChargesValueCheck, type: :model do
expect(page.subsection).to eq(subsection) expect(page.subsection).to eq(subsection)
end end
it "has the correct header" do
expect(page.header).to be nil
end
it "has the correct description" do it "has the correct description" do
expect(page.description).to be nil expect(page.description).to be nil
end end

4
spec/models/form/lettings/pages/created_by_spec.rb

@ -47,10 +47,6 @@ RSpec.describe Form::Lettings::Pages::CreatedBy, type: :model do
expect(page.id).to eq("assigned_to") expect(page.id).to eq("assigned_to")
end end
it "has the correct header" do
expect(page.header).to be_nil
end
it "has the correct description" do it "has the correct description" do
expect(page.description).to be_nil expect(page.description).to be_nil
end end

4
spec/models/form/lettings/pages/females_in_soft_age_range_in_pregnant_household_person_age_value_check_spec.rb

@ -11,10 +11,6 @@ RSpec.describe Form::Lettings::Pages::FemalesInSoftAgeRangeInPregnantHouseholdPe
expect(page.subsection).to eq(subsection) expect(page.subsection).to eq(subsection)
end end
it "has the correct header" do
expect(page.header).to be nil
end
it "has the correct description" do it "has the correct description" do
expect(page.description).to be nil expect(page.description).to be nil
end end

4
spec/models/form/lettings/pages/females_in_soft_age_range_in_pregnant_household_person_value_check_spec.rb

@ -11,10 +11,6 @@ RSpec.describe Form::Lettings::Pages::FemalesInSoftAgeRangeInPregnantHouseholdPe
expect(page.subsection).to eq(subsection) expect(page.subsection).to eq(subsection)
end end
it "has the correct header" do
expect(page.header).to be nil
end
it "has the correct description" do it "has the correct description" do
expect(page.description).to be nil expect(page.description).to be nil
end end

4
spec/models/form/lettings/pages/first_time_property_let_as_social_housing_spec.rb

@ -25,10 +25,6 @@ RSpec.describe Form::Lettings::Pages::FirstTimePropertyLetAsSocialHousing, type:
expect(page.id).to eq("first_time_property_let_as_social_housing") expect(page.id).to eq("first_time_property_let_as_social_housing")
end end
it "has the correct header" do
expect(page.header).to be_nil
end
it "has the correct description" do it "has the correct description" do
expect(page.description).to be_nil expect(page.description).to be_nil
end end

4
spec/models/form/lettings/pages/lead_tenant_ethnic_background_white_spec.rb

@ -25,10 +25,6 @@ RSpec.describe Form::Lettings::Pages::LeadTenantEthnicBackgroundWhite, type: :mo
expect(page.id).to eq("lead_tenant_ethnic_background_white") expect(page.id).to eq("lead_tenant_ethnic_background_white")
end end
it "has the correct header" do
expect(page.header).to be_nil
end
it "has the correct description" do it "has the correct description" do
expect(page.description).to be_nil expect(page.description).to be_nil
end end

4
spec/models/form/lettings/pages/location_spec.rb

@ -25,10 +25,6 @@ RSpec.describe Form::Lettings::Pages::Location, type: :model do
expect(page.id).to eq("location") expect(page.id).to eq("location")
end end
it "has the correct header" do
expect(page.header).to eq("Location")
end
it "has the correct description" do it "has the correct description" do
expect(page.description).to be_nil expect(page.description).to be_nil
end end

4
spec/models/form/lettings/pages/managing_organisation_spec.rb

@ -19,10 +19,6 @@ RSpec.describe Form::Lettings::Pages::ManagingOrganisation, type: :model do
expect(page.id).to eq("managing_organisation") expect(page.id).to eq("managing_organisation")
end end
it "has the correct header" do
expect(page.header).to be_nil
end
it "has the correct description" do it "has the correct description" do
expect(page.description).to be_nil expect(page.description).to be_nil
end end

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

@ -19,10 +19,6 @@ RSpec.describe Form::Lettings::Pages::MaxRentValueCheck, type: :model do
expect(page.id).to eq("max_rent_value_check") expect(page.id).to eq("max_rent_value_check")
end end
it "has the correct header" do
expect(page.header).to be_nil
end
it "has correct depends_on" do it "has correct depends_on" do
expect(page.depends_on).to eq([{ "rent_in_soft_max_range?" => true }]) expect(page.depends_on).to eq([{ "rent_in_soft_max_range?" => true }])
end end

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

@ -11,10 +11,6 @@ RSpec.describe Form::Lettings::Pages::MinRentValueCheck, type: :model do
expect(page.subsection).to eq(subsection) expect(page.subsection).to eq(subsection)
end end
it "has the correct header" do
expect(page.header).to be nil
end
it "has the correct description" do it "has the correct description" do
expect(page.description).to be nil expect(page.description).to be nil
end end

4
spec/models/form/lettings/pages/multiple_partners_value_check_spec.rb

@ -13,10 +13,6 @@ RSpec.describe Form::Lettings::Pages::MultiplePartnersValueCheck, type: :model d
expect(page.subsection).to eq(subsection) expect(page.subsection).to eq(subsection)
end end
it "has the correct header" do
expect(page.header).to be_nil
end
it "has the correct description" do it "has the correct description" do
expect(page.description).to be_nil expect(page.description).to be_nil
end end

4
spec/models/form/lettings/pages/needs_type_spec.rb

@ -19,10 +19,6 @@ RSpec.describe Form::Lettings::Pages::NeedsType, type: :model do
expect(page.id).to eq("needs_type") expect(page.id).to eq("needs_type")
end end
it "has the correct header" do
expect(page.header).to be_nil
end
it "has the correct description" do it "has the correct description" do
expect(page.description).to be_nil expect(page.description).to be_nil
end end

4
spec/models/form/lettings/pages/net_income_value_check_spec.rb

@ -19,10 +19,6 @@ RSpec.describe Form::Lettings::Pages::NetIncomeValueCheck, type: :model do
expect(page.id).to eq("net_income_value_check") expect(page.id).to eq("net_income_value_check")
end end
it "has the correct header" do
expect(page.header).to be_nil
end
it "has correct depends_on" do it "has correct depends_on" do
expect(page.depends_on).to eq([{ "net_income_soft_validation_triggered?" => true }]) expect(page.depends_on).to eq([{ "net_income_soft_validation_triggered?" => true }])
end end

4
spec/models/form/lettings/pages/no_address_found_spec.rb

@ -20,10 +20,6 @@ RSpec.describe Form::Lettings::Pages::NoAddressFound, type: :model do
expect(page.id).to eq("no_address_found") expect(page.id).to eq("no_address_found")
end end
it "has the correct header" do
expect(page.header).to be_nil
end
it "has correct depends_on" do it "has correct depends_on" do
expect(page.depends_on).to eq([{ "address_options_present?" => false, expect(page.depends_on).to eq([{ "address_options_present?" => false,
"is_supported_housing?" => false, "is_supported_housing?" => false,

4
spec/models/form/lettings/pages/no_females_pregnant_household_person_age_value_check_spec.rb

@ -11,10 +11,6 @@ RSpec.describe Form::Lettings::Pages::NoFemalesPregnantHouseholdPersonAgeValueCh
expect(page.subsection).to eq(subsection) expect(page.subsection).to eq(subsection)
end end
it "has the correct header" do
expect(page.header).to be nil
end
it "has the correct description" do it "has the correct description" do
expect(page.description).to be nil expect(page.description).to be nil
end end

4
spec/models/form/lettings/pages/no_females_pregnant_household_person_value_check_spec.rb

@ -11,10 +11,6 @@ RSpec.describe Form::Lettings::Pages::NoFemalesPregnantHouseholdPersonValueCheck
expect(page.subsection).to eq(subsection) expect(page.subsection).to eq(subsection)
end end
it "has the correct header" do
expect(page.header).to be nil
end
it "has the correct description" do it "has the correct description" do
expect(page.description).to be nil expect(page.description).to be nil
end end

4
spec/models/form/lettings/pages/partner_under16_value_check_spec.rb

@ -13,10 +13,6 @@ RSpec.describe Form::Lettings::Pages::PartnerUnder16ValueCheck, type: :model do
expect(page.subsection).to eq(subsection) expect(page.subsection).to eq(subsection)
end end
it "has the correct header" do
expect(page.header).to be_nil
end
it "has the correct description" do it "has the correct description" do
expect(page.description).to be_nil expect(page.description).to be_nil
end end

4
spec/models/form/lettings/pages/person_age_spec.rb

@ -12,10 +12,6 @@ RSpec.describe Form::Lettings::Pages::PersonAge, type: :model do
expect(page.subsection).to eq(subsection) expect(page.subsection).to eq(subsection)
end end
it "has the correct header" do
expect(page.header).to be nil
end
it "has the correct description" do it "has the correct description" do
expect(page.description).to be nil expect(page.description).to be nil
end end

4
spec/models/form/lettings/pages/person_gender_identity_spec.rb

@ -11,10 +11,6 @@ RSpec.describe Form::Lettings::Pages::PersonGenderIdentity, type: :model do
expect(page.subsection).to eq(subsection) expect(page.subsection).to eq(subsection)
end end
it "has the correct header" do
expect(page.header).to be nil
end
it "has the correct description" do it "has the correct description" do
expect(page.description).to be nil expect(page.description).to be nil
end end

4
spec/models/form/lettings/pages/person_known_spec.rb

@ -11,10 +11,6 @@ RSpec.describe Form::Lettings::Pages::PersonKnown, type: :model do
expect(page.subsection).to eq(subsection) expect(page.subsection).to eq(subsection)
end end
it "has the correct header" do
expect(page.header).to eq("You’ve given us the details for 1 person in the household")
end
it "has the correct description" do it "has the correct description" do
expect(page.description).to be nil expect(page.description).to be nil
end end

4
spec/models/form/lettings/pages/person_over_retirement_value_check_spec.rb

@ -11,10 +11,6 @@ RSpec.describe Form::Lettings::Pages::PersonOverRetirementValueCheck, type: :mod
expect(page.subsection).to eq(subsection) expect(page.subsection).to eq(subsection)
end end
it "has the correct header" do
expect(page.header).to be nil
end
it "has the correct description" do it "has the correct description" do
expect(page.description).to be nil expect(page.description).to be nil
end end

4
spec/models/form/lettings/pages/person_relationship_to_lead_spec.rb

@ -11,10 +11,6 @@ RSpec.describe Form::Lettings::Pages::PersonRelationshipToLead, type: :model do
expect(page.subsection).to eq(subsection) expect(page.subsection).to eq(subsection)
end end
it "has the correct header" do
expect(page.header).to be nil
end
it "has the correct description" do it "has the correct description" do
expect(page.description).to be nil expect(page.description).to be nil
end end

4
spec/models/form/lettings/pages/person_under_retirement_value_check_spec.rb

@ -11,10 +11,6 @@ RSpec.describe Form::Lettings::Pages::PersonUnderRetirementValueCheck, type: :mo
expect(page.subsection).to eq(subsection) expect(page.subsection).to eq(subsection)
end end
it "has the correct header" do
expect(page.header).to be nil
end
it "has the correct description" do it "has the correct description" do
expect(page.description).to be nil expect(page.description).to be nil
end end

4
spec/models/form/lettings/pages/person_working_situation_spec.rb

@ -11,10 +11,6 @@ RSpec.describe Form::Lettings::Pages::PersonWorkingSituation, type: :model do
expect(page.subsection).to eq(subsection) expect(page.subsection).to eq(subsection)
end end
it "has the correct header" do
expect(page.header).to be nil
end
it "has the correct description" do it "has the correct description" do
expect(page.description).to be nil expect(page.description).to be nil
end end

4
spec/models/form/lettings/pages/previous_housing_situation_renewal_spec.rb

@ -17,10 +17,6 @@ RSpec.describe Form::Lettings::Pages::PreviousHousingSituationRenewal, type: :mo
expect(page.id).to eq("previous_housing_situation_renewal") expect(page.id).to eq("previous_housing_situation_renewal")
end end
it "has the correct header" do
expect(page.header).to be_nil
end
it "has the correct description" do it "has the correct description" do
expect(page.description).to be_nil expect(page.description).to be_nil
end end

4
spec/models/form/lettings/pages/previous_housing_situation_spec.rb

@ -17,10 +17,6 @@ RSpec.describe Form::Lettings::Pages::PreviousHousingSituation, type: :model do
expect(page.id).to eq("previous_housing_situation") expect(page.id).to eq("previous_housing_situation")
end end
it "has the correct header" do
expect(page.header).to be_nil
end
it "has the correct description" do it "has the correct description" do
expect(page.description).to be_nil expect(page.description).to be_nil
end end

4
spec/models/form/lettings/pages/previous_local_authority_spec.rb

@ -24,10 +24,6 @@ RSpec.describe Form::Lettings::Pages::PreviousLocalAuthority, type: :model do
expect(page.id).to eq("previous_local_authority") expect(page.id).to eq("previous_local_authority")
end end
it "has the correct header" do
expect(page.header).to be_nil
end
it "has the correct description" do it "has the correct description" do
expect(page.description).to be_nil expect(page.description).to be_nil
end end

4
spec/models/form/lettings/pages/previous_postcode_spec.rb

@ -24,10 +24,6 @@ RSpec.describe Form::Lettings::Pages::PreviousPostcode, type: :model do
expect(page.id).to eq("previous_postcode") expect(page.id).to eq("previous_postcode")
end end
it "has the correct header" do
expect(page.header).to be_nil
end
it "has the correct description" do it "has the correct description" do
expect(page.description).to be_nil expect(page.description).to be_nil
end end

4
spec/models/form/lettings/pages/property_local_authority_spec.rb

@ -28,10 +28,6 @@ RSpec.describe Form::Lettings::Pages::PropertyLocalAuthority, type: :model do
expect(page.id).to eq("property_local_authority") expect(page.id).to eq("property_local_authority")
end end
it "has the correct header" do
expect(page.header).to be_nil
end
it "has the correct description" do it "has the correct description" do
expect(page.description).to be_nil expect(page.description).to be_nil
end end

4
spec/models/form/lettings/pages/property_number_of_times_relet_spec.rb

@ -19,10 +19,6 @@ RSpec.describe Form::Lettings::Pages::PropertyNumberOfTimesRelet, type: :model d
expect(page.id).to eq("property_number_of_times_relet") expect(page.id).to eq("property_number_of_times_relet")
end end
it "has the correct header" do
expect(page.header).to be_nil
end
it "has the correct description" do it "has the correct description" do
expect(page.description).to be_nil expect(page.description).to be_nil
end end

4
spec/models/form/lettings/pages/property_reference_spec.rb

@ -19,10 +19,6 @@ RSpec.describe Form::Lettings::Pages::PropertyReference, type: :model do
expect(page.id).to eq("property_reference") expect(page.id).to eq("property_reference")
end end
it "has the correct header" do
expect(page.header).to be_nil
end
it "has the correct description" do it "has the correct description" do
expect(page.description).to be_nil expect(page.description).to be_nil
end end

4
spec/models/form/lettings/pages/property_wheelchair_accessible_spec.rb

@ -21,10 +21,6 @@ RSpec.describe Form::Lettings::Pages::PropertyWheelchairAccessible, type: :model
expect(page.id).to eq("property_wheelchair_accessible") expect(page.id).to eq("property_wheelchair_accessible")
end end
it "has the correct header" do
expect(page.header).to be_nil
end
it "has the correct description" do it "has the correct description" do
expect(page.description).to be_nil expect(page.description).to be_nil
end end

4
spec/models/form/lettings/pages/renewal_spec.rb

@ -25,10 +25,6 @@ RSpec.describe Form::Lettings::Pages::Renewal, type: :model do
expect(page.id).to eq("renewal") expect(page.id).to eq("renewal")
end end
it "has the correct header" do
expect(page.header).to be_nil
end
it "has the correct description" do it "has the correct description" do
expect(page.description).to be_nil expect(page.description).to be_nil
end end

4
spec/models/form/lettings/pages/rent_type_spec.rb

@ -25,10 +25,6 @@ RSpec.describe Form::Lettings::Pages::RentType, type: :model do
expect(page.id).to eq("rent_type") expect(page.id).to eq("rent_type")
end end
it "has the correct header" do
expect(page.header).to eq("Rent Type")
end
it "has the correct description" do it "has the correct description" do
expect(page.description).to be_nil expect(page.description).to be_nil
end end

4
spec/models/form/lettings/pages/scheme_spec.rb

@ -19,10 +19,6 @@ RSpec.describe Form::Lettings::Pages::Scheme, type: :model do
expect(page.id).to eq("scheme") expect(page.id).to eq("scheme")
end end
it "has the correct header" do
expect(page.header).to eq("Scheme")
end
it "has the correct description" do it "has the correct description" do
expect(page.description).to be_nil expect(page.description).to be_nil
end end

4
spec/models/form/lettings/pages/sheltered_accommodation_spec.rb

@ -17,10 +17,6 @@ RSpec.describe Form::Lettings::Pages::ShelteredAccommodation, type: :model do
expect(page.id).to eq("sheltered_accommodation") expect(page.id).to eq("sheltered_accommodation")
end end
it "has the correct header" do
expect(page.header).to be_nil
end
it "has the correct description" do it "has the correct description" do
expect(page.description).to be_nil expect(page.description).to be_nil
end end

4
spec/models/form/lettings/pages/starter_tenancy_type_spec.rb

@ -23,10 +23,6 @@ RSpec.describe Form::Lettings::Pages::StarterTenancyType, type: :model do
expect(page.id).to eq("starter_tenancy_type") expect(page.id).to eq("starter_tenancy_type")
end end
it "has the correct header" do
expect(page.header).to be_nil
end
it "has the correct description" do it "has the correct description" do
expect(page.description).to be_nil expect(page.description).to be_nil
end end

4
spec/models/form/lettings/pages/stock_owner_spec.rb

@ -20,10 +20,6 @@ RSpec.describe Form::Lettings::Pages::StockOwner, type: :model do
expect(page.id).to eq("stock_owner") expect(page.id).to eq("stock_owner")
end end
it "has the correct header" do
expect(page.header).to be_nil
end
it "has the correct description" do it "has the correct description" do
expect(page.description).to be_nil expect(page.description).to be_nil
end end

4
spec/models/form/lettings/pages/tenancy_length_periodic_spec.rb

@ -17,10 +17,6 @@ RSpec.describe Form::Lettings::Pages::TenancyLengthPeriodic, type: :model do
expect(page.id).to eq "tenancy_length_periodic" expect(page.id).to eq "tenancy_length_periodic"
end end
it "has the correct header" do
expect(page.header).to be_nil
end
it "has the correct description" do it "has the correct description" do
expect(page.description).to be_nil expect(page.description).to be_nil
end end

4
spec/models/form/lettings/pages/tenancy_length_spec.rb

@ -17,10 +17,6 @@ RSpec.describe Form::Lettings::Pages::TenancyLength, type: :model do
expect(page.id).to eq "tenancy_length" expect(page.id).to eq "tenancy_length"
end end
it "has the correct header" do
expect(page.header).to be_nil
end
it "has the correct description" do it "has the correct description" do
expect(page.description).to be_nil expect(page.description).to be_nil
end end

4
spec/models/form/lettings/pages/tenancy_start_date_spec.rb

@ -19,10 +19,6 @@ RSpec.describe Form::Lettings::Pages::TenancyStartDate, type: :model do
expect(page.id).to eq("tenancy_start_date") expect(page.id).to eq("tenancy_start_date")
end end
it "has the correct header" do
expect(page.header).to be nil
end
it "has the correct description" do it "has the correct description" do
expect(page.description).to be_nil expect(page.description).to be_nil
end end

4
spec/models/form/lettings/pages/tenancy_type_spec.rb

@ -17,10 +17,6 @@ RSpec.describe Form::Lettings::Pages::TenancyType, type: :model do
expect(page.id).to eq "tenancy_type" expect(page.id).to eq "tenancy_type"
end end
it "has the correct header" do
expect(page.header).to be_nil
end
it "has the correct description" do it "has the correct description" do
expect(page.description).to be_nil expect(page.description).to be_nil
end end

4
spec/models/form/lettings/pages/tenant_code_spec.rb

@ -19,10 +19,6 @@ RSpec.describe Form::Lettings::Pages::TenantCode, type: :model do
expect(page.id).to eq("tenant_code") expect(page.id).to eq("tenant_code")
end end
it "has the correct header" do
expect(page.header).to be_nil
end
it "has the correct description" do it "has the correct description" do
expect(page.description).to be_nil expect(page.description).to be_nil
end end

4
spec/models/form/lettings/pages/uprn_confirmation_spec.rb

@ -19,10 +19,6 @@ RSpec.describe Form::Lettings::Pages::UprnConfirmation, type: :model do
expect(page.id).to eq("uprn_confirmation") expect(page.id).to eq("uprn_confirmation")
end end
it "has the correct header" do
expect(page.header).to eq("We found an address that might be this property")
end
it "has the correct description" do it "has the correct description" do
expect(page.description).to be_nil expect(page.description).to be_nil
end end

4
spec/models/form/lettings/pages/uprn_selection_spec.rb

@ -20,10 +20,6 @@ RSpec.describe Form::Lettings::Pages::UprnSelection, type: :model do
expect(page.id).to eq("uprn_selection") expect(page.id).to eq("uprn_selection")
end end
it "has the correct header" do
expect(page.header).to eq("We found some addresses that might be this property")
end
it "has the correct description" do it "has the correct description" do
expect(page.description).to be_nil expect(page.description).to be_nil
end end

4
spec/models/form/lettings/pages/uprn_spec.rb

@ -25,10 +25,6 @@ RSpec.describe Form::Lettings::Pages::Uprn, type: :model do
expect(page.id).to eq("uprn") expect(page.id).to eq("uprn")
end end
it "has the correct header" do
expect(page.header).to be_nil
end
it "has the correct description" do it "has the correct description" do
expect(page.description).to be_nil expect(page.description).to be_nil
end end

4
spec/models/form/lettings/pages/void_date_spec.rb

@ -19,10 +19,6 @@ RSpec.describe Form::Lettings::Pages::VoidDate, type: :model do
expect(page.id).to eq("void_date") expect(page.id).to eq("void_date")
end end
it "has the correct header" do
expect(page.header).to eq("Void date")
end
it "has the correct description" do it "has the correct description" do
expect(page.description).to be_nil expect(page.description).to be_nil
end end

12
spec/models/form/lettings/questions/address_line1_for_address_matcher_spec.rb

@ -16,18 +16,10 @@ RSpec.describe Form::Lettings::Questions::AddressLine1ForAddressMatcher, type: :
expect(question.id).to eq("address_line1_input") expect(question.id).to eq("address_line1_input")
end end
it "has the correct header" do
expect(question.header).to eq("Address line 1")
end
it "has the correct error label" do it "has the correct error label" do
expect(question.error_label).to eq("Address line 1") expect(question.error_label).to eq("Address line 1")
end end
it "has the correct check_answer_label" do
expect(question.check_answer_label).to eq("Find address")
end
it "has the correct question_number" do it "has the correct question_number" do
expect(question.question_number).to eq(nil) expect(question.question_number).to eq(nil)
end end
@ -40,10 +32,6 @@ RSpec.describe Form::Lettings::Questions::AddressLine1ForAddressMatcher, type: :
expect(question.derived?(nil)).to be false expect(question.derived?(nil)).to be false
end end
it "has the correct hint" do
expect(question.hint_text).to be_nil
end
it "has the correct answer label" do it "has the correct answer label" do
expect(question.answer_label(log)).to eq("Address line 1\nAA1 1AA") expect(question.answer_label(log)).to eq("Address line 1\nAA1 1AA")
end end

12
spec/models/form/lettings/questions/address_line1_spec.rb

@ -15,18 +15,10 @@ RSpec.describe Form::Lettings::Questions::AddressLine1, type: :model do
expect(question.id).to eq("address_line1") expect(question.id).to eq("address_line1")
end end
it "has the correct header" do
expect(question.header).to eq("Address line 1")
end
it "has the correct error label" do it "has the correct error label" do
expect(question.error_label).to eq("Address line 1") expect(question.error_label).to eq("Address line 1")
end end
it "has the correct check_answer_label" do
expect(question.check_answer_label).to eq("Address lines 1 and 2")
end
it "has the correct question_number" do it "has the correct question_number" do
expect(question.question_number).to eq(12) expect(question.question_number).to eq(12)
end end
@ -39,10 +31,6 @@ RSpec.describe Form::Lettings::Questions::AddressLine1, type: :model do
expect(question.derived?(nil)).to be false expect(question.derived?(nil)).to be false
end end
it "has the correct hint" do
expect(question.hint_text).to be_nil
end
it "has the correct inferred check answers value" do it "has the correct inferred check answers value" do
expect(question.inferred_check_answers_value).to be_nil expect(question.inferred_check_answers_value).to be_nil
end end

12
spec/models/form/lettings/questions/address_line2_spec.rb

@ -15,14 +15,6 @@ RSpec.describe Form::Lettings::Questions::AddressLine2, type: :model do
expect(question.id).to eq("address_line2") expect(question.id).to eq("address_line2")
end end
it "has the correct header" do
expect(question.header).to eq("Address line 2 (optional)")
end
it "has the correct check_answer_label" do
expect(question.check_answer_label).to be_nil
end
it "has the correct type" do it "has the correct type" do
expect(question.type).to eq("text") expect(question.type).to eq("text")
end end
@ -31,10 +23,6 @@ RSpec.describe Form::Lettings::Questions::AddressLine2, type: :model do
expect(question.derived?(nil)).to be false expect(question.derived?(nil)).to be false
end end
it "has the correct hint" do
expect(question.hint_text).to be_nil
end
it "has the correct inferred check answers value" do it "has the correct inferred check answers value" do
expect(question.inferred_check_answers_value).to be_nil expect(question.inferred_check_answers_value).to be_nil
end end

24
spec/models/form/lettings/questions/age1_known_spec.rb

@ -33,18 +33,10 @@ RSpec.describe Form::Lettings::Questions::Age1Known, type: :model do
}) })
end end
it "has the correct check_answer_label" do
expect(question.check_answer_label).to eq("")
end
it "has the correct id" do it "has the correct id" do
expect(question.id).to eq("age1_known") expect(question.id).to eq("age1_known")
end end
it "has the correct header" do
expect(question.header).to eq("Do you know the lead tenant’s age?")
end
it "has correct conditional for" do it "has correct conditional for" do
expect(question.conditional_for).to eq({ expect(question.conditional_for).to eq({
"age1" => [0], "age1" => [0],
@ -69,20 +61,4 @@ RSpec.describe Form::Lettings::Questions::Age1Known, type: :model do
it "has the correct check_answers_card_number" do it "has the correct check_answers_card_number" do
expect(question.check_answers_card_number).to eq(1) expect(question.check_answers_card_number).to eq(1)
end end
context "with 2023/24 form" do
it "has the correct hint" do
expect(question.hint_text).to eq("The ’lead’ or ’main’ tenant is the person in the household who does the most paid work. If several people do the same paid work, the lead tenant is whoever is the oldest.")
end
end
context "with 2024/25 form" do
before do
allow(form).to receive(:start_year_after_2024?).and_return(true)
end
it "has the correct hint" do
expect(question.hint_text).to eq("The ’lead’ or ’main’ tenant is the person in the household who does the most paid work. If several people do the same amount of paid work, the lead tenant is whoever is the oldest.")
end
end
end end

16
spec/models/form/lettings/questions/age_known_spec.rb

@ -26,23 +26,11 @@ RSpec.describe Form::Lettings::Questions::AgeKnown, type: :model do
}) })
end end
it "has the correct hint" do
expect(question.hint_text).to eq("")
end
it "has the correct check_answer_label" do
expect(question.check_answer_label).to eq("")
end
context "with person 2" do context "with person 2" do
it "has the correct id" do it "has the correct id" do
expect(question.id).to eq("age2_known") expect(question.id).to eq("age2_known")
end end
it "has the correct header" do
expect(question.header).to eq("Do you know person 2’s age?")
end
it "has correct conditional for" do it "has correct conditional for" do
expect(question.conditional_for).to eq({ expect(question.conditional_for).to eq({
"age2" => [0], "age2" => [0],
@ -76,10 +64,6 @@ RSpec.describe Form::Lettings::Questions::AgeKnown, type: :model do
expect(question.id).to eq("age3_known") expect(question.id).to eq("age3_known")
end end
it "has the correct header" do
expect(question.header).to eq("Do you know person 3’s age?")
end
it "has correct conditional for" do it "has correct conditional for" do
expect(question.conditional_for).to eq({ expect(question.conditional_for).to eq({
"age3" => [0], "age3" => [0],

26
spec/models/form/lettings/questions/age_spec.rb

@ -12,10 +12,6 @@ RSpec.describe Form::Lettings::Questions::Age, type: :model do
expect(question.page).to eq(page) expect(question.page).to eq(page)
end end
it "has the correct header" do
expect(question.header).to eq("Age")
end
it "has the correct type" do it "has the correct type" do
expect(question.type).to eq("numeric") expect(question.type).to eq("numeric")
end end
@ -24,20 +20,6 @@ RSpec.describe Form::Lettings::Questions::Age, type: :model do
expect(question.derived?(nil)).to be false expect(question.derived?(nil)).to be false
end end
context "when child" do
let(:person_type) { "child" }
it "has the correct hint" do
expect(question.hint_text).to eq("For a child under 1, enter 1")
end
end
context "when not child" do
it "has no hint" do
expect(question.hint_text).to be nil
end
end
it "has the correct min" do it "has the correct min" do
expect(question.min).to eq(1) expect(question.min).to eq(1)
end end
@ -55,10 +37,6 @@ RSpec.describe Form::Lettings::Questions::Age, type: :model do
expect(question.id).to eq("age2") expect(question.id).to eq("age2")
end end
it "has the correct check_answer_label" do
expect(question.check_answer_label).to eq("Person 2’s age")
end
it "has the correct inferred check answers value" do it "has the correct inferred check answers value" do
expect(question.inferred_check_answers_value).to eq([ expect(question.inferred_check_answers_value).to eq([
{ {
@ -80,10 +58,6 @@ RSpec.describe Form::Lettings::Questions::Age, type: :model do
expect(question.id).to eq("age3") expect(question.id).to eq("age3")
end end
it "has the correct check_answer_label" do
expect(question.check_answer_label).to eq("Person 3’s age")
end
it "has the correct inferred check answers value" do it "has the correct inferred check answers value" do
expect(question.inferred_check_answers_value).to eq([ expect(question.inferred_check_answers_value).to eq([
{ {

22
spec/models/form/lettings/questions/beds_spec.rb

@ -7,28 +7,6 @@ RSpec.describe Form::Lettings::Questions::Beds, type: :model do
let(:subsection) { instance_double(Form::Subsection, form:) } let(:subsection) { instance_double(Form::Subsection, form:) }
let(:form) { instance_double(Form, start_date: Time.zone.local(2023, 4, 1)) } let(:form) { instance_double(Form, start_date: Time.zone.local(2023, 4, 1)) }
describe "the hint text" do
context "when the start date is before 24/25" do
before do
allow(form).to receive(:start_year_after_2024?).and_return false
end
it "has the correct hint_text" do
expect(question.hint_text).to eq("If shared accommodation, enter the number of bedrooms occupied by this household. A bedsit has 1 bedroom.")
end
end
context "when the start date is 24/25 or after" do
before do
allow(form).to receive(:start_year_after_2024?).and_return true
end
it "has the correct hint_text" do
expect(question.hint_text).to eq("If shared accommodation, enter the number of bedrooms occupied by this household.")
end
end
end
describe "whether the field is derived" do describe "whether the field is derived" do
context "when the log is a bedsit" do context "when the log is a bedsit" do
let(:log) { build(:lettings_log, unittype_gn: 2) } let(:log) { build(:lettings_log, unittype_gn: 2) }

12
spec/models/form/lettings/questions/care_home_charges_value_check_spec.rb

@ -14,14 +14,6 @@ RSpec.describe Form::Lettings::Questions::CareHomeChargesValueCheck, type: :mode
expect(question.id).to eq("carehome_charges_value_check") expect(question.id).to eq("carehome_charges_value_check")
end end
it "has the correct header" do
expect(question.header).to eq("Are you sure there are no care home charges?")
end
it "has the correct check_answer_label" do
expect(question.check_answer_label).to eq("Care home charges confirmation")
end
it "has the correct type" do it "has the correct type" do
expect(question.type).to eq("interruption_screen") expect(question.type).to eq("interruption_screen")
end end
@ -30,10 +22,6 @@ RSpec.describe Form::Lettings::Questions::CareHomeChargesValueCheck, type: :mode
expect(question.derived?(nil)).to be false expect(question.derived?(nil)).to be false
end end
it "has the correct hint" do
expect(question.hint_text).to be_nil
end
it "has the correct answer_options" do it "has the correct answer_options" do
expect(question.answer_options).to eq({ expect(question.answer_options).to eq({
"0" => { "value" => "Yes" }, "0" => { "value" => "Yes" },

12
spec/models/form/lettings/questions/county_spec.rb

@ -15,14 +15,6 @@ RSpec.describe Form::Lettings::Questions::County, type: :model do
expect(question.id).to eq("county") expect(question.id).to eq("county")
end end
it "has the correct header" do
expect(question.header).to eq("County (optional)")
end
it "has the correct check_answer_label" do
expect(question.check_answer_label).to eq("County")
end
it "has the correct question_number" do it "has the correct question_number" do
expect(question.question_number).to eq(12) expect(question.question_number).to eq(12)
end end
@ -35,10 +27,6 @@ RSpec.describe Form::Lettings::Questions::County, type: :model do
expect(question.derived?(nil)).to be false expect(question.derived?(nil)).to be false
end end
it "has the correct hint" do
expect(question.hint_text).to be_nil
end
it "has the correct inferred check answers value" do it "has the correct inferred check answers value" do
expect(question.inferred_check_answers_value).to be_nil expect(question.inferred_check_answers_value).to be_nil
end end

12
spec/models/form/lettings/questions/created_by_id_spec.rb

@ -17,22 +17,10 @@ RSpec.describe Form::Lettings::Questions::CreatedById, type: :model do
expect(question.id).to eq("assigned_to_id") expect(question.id).to eq("assigned_to_id")
end end
it "has the correct header" do
expect(question.header).to eq("Which user are you creating this log for?")
end
it "has the correct check_answer_label" do
expect(question.check_answer_label).to eq("Log owner")
end
it "has the correct type" do it "has the correct type" do
expect(question.type).to eq("select") expect(question.type).to eq("select")
end end
it "has the correct hint_text" do
expect(question.hint_text).to be_nil
end
it "has the correct answer options" do it "has the correct answer options" do
expect(question.answer_options).to eq({ "" => "Select an option" }) expect(question.answer_options).to eq({ "" => "Select an option" })
end end

12
spec/models/form/lettings/questions/declaration_spec.rb

@ -23,14 +23,6 @@ RSpec.describe Form::Lettings::Questions::Declaration, type: :model do
expect(question.id).to eq("declaration") expect(question.id).to eq("declaration")
end end
it "has the correct header" do
expect(question.header).to eq("Declaration")
end
it "has the correct check_answer_label" do
expect(question.check_answer_label).to eq("Tenant has seen the privacy notice")
end
it "has the correct type" do it "has the correct type" do
expect(question.type).to eq("checkbox") expect(question.type).to eq("checkbox")
end end
@ -39,10 +31,6 @@ RSpec.describe Form::Lettings::Questions::Declaration, type: :model do
expect(question.derived?(nil)).to be false expect(question.derived?(nil)).to be false
end end
it "has the correct hint" do
expect(question.hint_text).to be_nil
end
context "when the form year is before 2024" do context "when the form year is before 2024" do
before do before do
allow(form).to receive(:start_year_after_2024?).and_return(false) allow(form).to receive(:start_year_after_2024?).and_return(false)

20
spec/models/form/lettings/questions/details_known_spec.rb

@ -19,23 +19,11 @@ RSpec.describe Form::Lettings::Questions::DetailsKnown, type: :model do
expect(question.derived?(nil)).to be false expect(question.derived?(nil)).to be false
end end
it "has the correct hint" do
expect(question.hint_text).to eq("You must provide details for everyone in the household if you know them.")
end
context "with person 2" do context "with person 2" do
it "has the correct id" do it "has the correct id" do
expect(question.id).to eq("details_known_2") expect(question.id).to eq("details_known_2")
end end
it "has the correct check_answer_label" do
expect(question.check_answer_label).to eq("Details known for person 2")
end
it "has the correct header" do
expect(question.header).to eq("Do you know details for person 2?")
end
it "has the correct check_answers_card_number" do it "has the correct check_answers_card_number" do
expect(question.check_answers_card_number).to eq(2) expect(question.check_answers_card_number).to eq(2)
end end
@ -48,14 +36,6 @@ RSpec.describe Form::Lettings::Questions::DetailsKnown, type: :model do
expect(question.id).to eq("details_known_3") expect(question.id).to eq("details_known_3")
end end
it "has the correct check_answer_label" do
expect(question.check_answer_label).to eq("Details known for person 3")
end
it "has the correct header" do
expect(question.header).to eq("Do you know details for person 3?")
end
it "has the correct check_answers_card_number" do it "has the correct check_answers_card_number" do
expect(question.check_answers_card_number).to eq(3) expect(question.check_answers_card_number).to eq(3)
end end

16
spec/models/form/lettings/questions/ethnic_white_spec.rb

@ -23,14 +23,6 @@ RSpec.describe Form::Lettings::Questions::EthnicWhite, type: :model do
expect(question.id).to eq("ethnic") expect(question.id).to eq("ethnic")
end end
it "has the correct header" do
expect(question.header).to eq("Which of the following best describes the lead tenant’s White background?")
end
it "has the correct check_answer_label" do
expect(question.check_answer_label).to eq("Lead tenant’s ethnic background")
end
it "has the correct type" do it "has the correct type" do
expect(question.type).to eq("radio") expect(question.type).to eq("radio")
end end
@ -48,10 +40,6 @@ RSpec.describe Form::Lettings::Questions::EthnicWhite, type: :model do
"3" => { "value" => "Any other White background" }, "3" => { "value" => "Any other White background" },
}) })
end end
it "has the correct hint_text" do
expect(question.hint_text).to eq("The lead tenant is the person in the household who does the most paid work. If several people do the same paid work, the lead tenant is whoever is the oldest.")
end
end end
context "with 2024/25 form" do context "with 2024/25 form" do
@ -68,10 +56,6 @@ RSpec.describe Form::Lettings::Questions::EthnicWhite, type: :model do
"3" => { "value" => "Any other White background" }, "3" => { "value" => "Any other White background" },
}) })
end end
it "has the correct hint_text" do
expect(question.hint_text).to eq("")
end
end end
it "has the correct check_answers_card_number" do it "has the correct check_answers_card_number" do

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save