diff --git a/app/models/form/lettings/pages/declaration.rb b/app/models/form/lettings/pages/declaration.rb index 89561817d..647e2ccee 100644 --- a/app/models/form/lettings/pages/declaration.rb +++ b/app/models/form/lettings/pages/declaration.rb @@ -2,7 +2,6 @@ class Form::Lettings::Pages::Declaration < ::Form::Page def initialize(id, hsh, subsection) super @id = "declaration" - @header = "Ministry of Housing, Communities and Local Government privacy notice" end def questions diff --git a/app/models/form/lettings/pages/location.rb b/app/models/form/lettings/pages/location.rb index ba357dc1b..b35a38f7c 100644 --- a/app/models/form/lettings/pages/location.rb +++ b/app/models/form/lettings/pages/location.rb @@ -8,7 +8,7 @@ class Form::Lettings::Pages::Location < ::Form::Page "scheme_has_large_number_of_locations?" => false, }, ] - @header = "Location" + @copy_key = "lettings.setup.location_id.less_than_twenty" @next_unresolved_page_id = :check_answers end diff --git a/app/models/form/lettings/pages/location_search.rb b/app/models/form/lettings/pages/location_search.rb index f27fae281..e77346fce 100644 --- a/app/models/form/lettings/pages/location_search.rb +++ b/app/models/form/lettings/pages/location_search.rb @@ -8,7 +8,7 @@ class Form::Lettings::Pages::LocationSearch < ::Form::Page "scheme_has_large_number_of_locations?" => true, }, ] - @header = "Location" + @copy_key = "lettings.setup.location_id.twenty_or_more" @next_unresolved_page_id = :check_answers end diff --git a/app/models/form/lettings/pages/rent_type.rb b/app/models/form/lettings/pages/rent_type.rb index b3e52d0e2..8353b0338 100644 --- a/app/models/form/lettings/pages/rent_type.rb +++ b/app/models/form/lettings/pages/rent_type.rb @@ -2,7 +2,7 @@ class Form::Lettings::Pages::RentType < ::Form::Page def initialize(_id, hsh, subsection) super("rent_type", hsh, subsection) @derived = true - @header = "Rent Type" + @copy_key = "lettings.setup.rent_type" end def questions diff --git a/app/models/form/lettings/pages/scheme.rb b/app/models/form/lettings/pages/scheme.rb index 06bb6eb9c..9ac87a756 100644 --- a/app/models/form/lettings/pages/scheme.rb +++ b/app/models/form/lettings/pages/scheme.rb @@ -6,7 +6,6 @@ class Form::Lettings::Pages::Scheme < ::Form::Page "needstype" => 2, }, ] - @header = "Scheme" @next_unresolved_page_id = "location" end diff --git a/app/models/form/lettings/questions/created_by_id.rb b/app/models/form/lettings/questions/created_by_id.rb index 1f260960f..ea6375152 100644 --- a/app/models/form/lettings/questions/created_by_id.rb +++ b/app/models/form/lettings/questions/created_by_id.rb @@ -4,8 +4,6 @@ class Form::Lettings::Questions::CreatedById < ::Form::Question def initialize(id, hsh, page) super @id = "assigned_to_id" - @check_answer_label = "Log owner" - @header = "Which user are you creating this log for?" @derived = true @type = "select" end diff --git a/app/models/form/lettings/questions/irproduct_other.rb b/app/models/form/lettings/questions/irproduct_other.rb index d0df0bec8..b004d5dc2 100644 --- a/app/models/form/lettings/questions/irproduct_other.rb +++ b/app/models/form/lettings/questions/irproduct_other.rb @@ -2,8 +2,7 @@ class Form::Lettings::Questions::IrproductOther < ::Form::Question def initialize(id, hsh, page) super @id = "irproduct_other" - @check_answer_label = "Product name" - @header = "Name of rent product" + @copy_key = "lettings.setup.rent_type.irproduct_other" @type = "text" @question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] if form.start_date.present? end diff --git a/app/models/form/lettings/questions/location_id.rb b/app/models/form/lettings/questions/location_id.rb index 59101592f..5bc316476 100644 --- a/app/models/form/lettings/questions/location_id.rb +++ b/app/models/form/lettings/questions/location_id.rb @@ -2,8 +2,7 @@ class Form::Lettings::Questions::LocationId < ::Form::Question def initialize(id, hsh, page) super @id = "location_id" - @check_answer_label = "Location" - @header = header_text + @copy_key = "lettings.setup.location_id.less_than_twenty" @type = "radio" @answer_options = answer_options @inferred_answers = { @@ -56,13 +55,5 @@ private false end - def header_text - if form.start_date && form.start_date.year >= 2023 - "Which location is this letting for?" - else - "Which location is this log for?" - end - end - QUESTION_NUMBER_FROM_YEAR = { 2023 => 10, 2024 => 5 }.freeze end diff --git a/app/models/form/lettings/questions/location_id_search.rb b/app/models/form/lettings/questions/location_id_search.rb index d085572e4..ecba28c38 100644 --- a/app/models/form/lettings/questions/location_id_search.rb +++ b/app/models/form/lettings/questions/location_id_search.rb @@ -2,10 +2,8 @@ class Form::Lettings::Questions::LocationIdSearch < ::Form::Question def initialize(id, hsh, page) super @id = "location_id" - @check_answer_label = "Location" - @header = header_text - @hint_text = '
This scheme has 20 or more locations.
Enter postcode or address.' @type = "select" + @copy_key = "lettings.setup.location_id.twenty_or_more" @answer_options = answer_options @inferred_answers = { "location.name": { @@ -52,13 +50,5 @@ private false end - def header_text - if form.start_date && form.start_date.year >= 2023 - "Which location is this letting for?" - else - "Which location is this log for?" - end - end - QUESTION_NUMBER_FROM_YEAR = { 2023 => 10, 2024 => 5 }.freeze end diff --git a/app/models/form/lettings/questions/managing_organisation.rb b/app/models/form/lettings/questions/managing_organisation.rb index 81847876e..e415837fe 100644 --- a/app/models/form/lettings/questions/managing_organisation.rb +++ b/app/models/form/lettings/questions/managing_organisation.rb @@ -2,8 +2,6 @@ class Form::Lettings::Questions::ManagingOrganisation < ::Form::Question def initialize(id, hsh, page) super @id = "managing_organisation_id" - @check_answer_label = "Managing agent" - @header = "Which organisation manages this letting?" @derived = true @type = "select" @question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] if form.start_date.present? diff --git a/app/models/form/lettings/questions/needs_type.rb b/app/models/form/lettings/questions/needs_type.rb index 158626843..4a0aff67b 100644 --- a/app/models/form/lettings/questions/needs_type.rb +++ b/app/models/form/lettings/questions/needs_type.rb @@ -2,9 +2,6 @@ class Form::Lettings::Questions::NeedsType < ::Form::Question def initialize(id, hsh, page) super @id = "needstype" - @check_answer_label = "Needs type" - @header = "What is the needs type?" - @hint_text = "General needs housing includes both self-contained and shared housing without support or specific adaptations. Supported housing can include direct access hostels, group homes, residential care and nursing homes." @type = "radio" @answer_options = ANSWER_OPTIONS @question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] if form.start_date.present? diff --git a/app/models/form/lettings/questions/property_reference.rb b/app/models/form/lettings/questions/property_reference.rb index f7d80829c..d4587ffe8 100644 --- a/app/models/form/lettings/questions/property_reference.rb +++ b/app/models/form/lettings/questions/property_reference.rb @@ -2,9 +2,6 @@ class Form::Lettings::Questions::PropertyReference < ::Form::Question def initialize(id, hsh, page) super @id = "propcode" - @check_answer_label = "Property reference" - @header = "What is the property reference?" - @hint_text = "This is how you usually refer to this property on your own systems." @type = "text" @width = 10 @question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] if form.start_date.present? diff --git a/app/models/form/lettings/questions/renewal.rb b/app/models/form/lettings/questions/renewal.rb index 2a32d1f16..e78d98247 100644 --- a/app/models/form/lettings/questions/renewal.rb +++ b/app/models/form/lettings/questions/renewal.rb @@ -2,11 +2,8 @@ class Form::Lettings::Questions::Renewal < ::Form::Question def initialize(id, hsh, page) super @id = "renewal" - @check_answer_label = "Property renewal" - @header = header_text @type = "radio" @answer_options = ANSWER_OPTIONS - @hint_text = hint_text @question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] if form.start_date.present? end @@ -16,21 +13,5 @@ class Form::Lettings::Questions::Renewal < ::Form::Question } .freeze - def header_text - if form.start_year_after_2024? - "Is this letting a renewal of social housing to the same tenant in the same property?" - else - "Is this letting a renewal?" - end - end - - def hint_text - if form.start_year_after_2024? - "If the property was previously being used as temporary accommodation, then answer 'no'" - else - "A renewal is a letting to the same tenant in the same property. If the property was previously being used as temporary accommodation, then answer 'no'" - end - end - QUESTION_NUMBER_FROM_YEAR = { 2023 => 4, 2024 => 6 }.freeze end diff --git a/app/models/form/lettings/questions/rent_type.rb b/app/models/form/lettings/questions/rent_type.rb index 7454cd752..818ead98a 100644 --- a/app/models/form/lettings/questions/rent_type.rb +++ b/app/models/form/lettings/questions/rent_type.rb @@ -2,8 +2,7 @@ class Form::Lettings::Questions::RentType < ::Form::Question def initialize(id, hsh, page) super @id = "rent_type" - @check_answer_label = "Rent type" - @header = "What is the rent type?" + @copy_key = "lettings.setup.rent_type.rent_type" @type = "radio" @top_guidance_partial = form.start_year_after_2024? ? "rent_type_definitions_2024" : "rent_type_definitions" @answer_options = form.start_year_after_2024? ? ANSWER_OPTIONS_2024 : ANSWER_OPTIONS diff --git a/app/models/form/lettings/questions/scheme_id.rb b/app/models/form/lettings/questions/scheme_id.rb index d5c58df61..862ef3130 100644 --- a/app/models/form/lettings/questions/scheme_id.rb +++ b/app/models/form/lettings/questions/scheme_id.rb @@ -1,8 +1,6 @@ class Form::Lettings::Questions::SchemeId < ::Form::Question def initialize(_id, hsh, page) super("scheme_id", hsh, page) - @check_answer_label = "Scheme name" - @header = "What scheme is this log for?" @type = "select" @answer_options = answer_options @top_guidance_partial = "finding_scheme" @@ -48,15 +46,6 @@ class Form::Lettings::Questions::SchemeId < ::Form::Question lettings_log.form.get_question("postcode_full", nil).label_from_value(lettings_log.postcode_full) unless lettings_log.scheme_has_multiple_locations? end - def hint_text - if form.start_year_after_2024? - "Enter postcode or scheme name.

- A supported housing scheme provides shared or self-contained housing for a particular client group, for example younger or vulnerable people." - else - "Enter postcode or scheme name" - end - end - private def supported_housing_selected?(lettings_log) diff --git a/app/models/form/lettings/questions/stock_owner.rb b/app/models/form/lettings/questions/stock_owner.rb index daa042004..6fc418b62 100644 --- a/app/models/form/lettings/questions/stock_owner.rb +++ b/app/models/form/lettings/questions/stock_owner.rb @@ -2,8 +2,6 @@ class Form::Lettings::Questions::StockOwner < ::Form::Question def initialize(id, hsh, page) super @id = "owning_organisation_id" - @check_answer_label = "Stock owner" - @header = "Which organisation owns this property?" @derived = true @type = "select" @question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] if form.start_date.present? diff --git a/app/models/form/lettings/questions/tenancy_start_date.rb b/app/models/form/lettings/questions/tenancy_start_date.rb index c7dc73627..cf1b556e7 100644 --- a/app/models/form/lettings/questions/tenancy_start_date.rb +++ b/app/models/form/lettings/questions/tenancy_start_date.rb @@ -2,8 +2,6 @@ class Form::Lettings::Questions::TenancyStartDate < ::Form::Question def initialize(id, hsh, page) super @id = "startdate" - @check_answer_label = "Tenancy start date" - @header = "What is the tenancy start date?" @type = "date" @unresolved_hint_text = "Some scheme details have changed, and now this log needs updating. Check that the tenancy start date is correct." @question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] if form.start_date.present? diff --git a/app/models/form/lettings/questions/tenant_code.rb b/app/models/form/lettings/questions/tenant_code.rb index 30b51525a..7b7be3cac 100644 --- a/app/models/form/lettings/questions/tenant_code.rb +++ b/app/models/form/lettings/questions/tenant_code.rb @@ -2,9 +2,6 @@ class Form::Lettings::Questions::TenantCode < ::Form::Question def initialize(id, hsh, page) super @id = "tenancycode" - @check_answer_label = "Tenant code" - @header = "What is the tenant code?" - @hint_text = "This is how you usually refer to this tenancy on your own systems." @type = "text" @width = 10 @question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] if form.start_date.present? diff --git a/config/locales/forms/2023/lettings/setup.en.yml b/config/locales/forms/2023/lettings/setup.en.yml new file mode 100644 index 000000000..5df98796a --- /dev/null +++ b/config/locales/forms/2023/lettings/setup.en.yml @@ -0,0 +1,81 @@ +en: + forms: + 2023: + lettings: + setup: + owning_organisation_id: + page_header: "" + check_answer_label: "Stock owner" + hint_text: "" + question_text: "Which organisation owns this property?" + + managing_organisation_id: + page_header: "" + check_answer_label: "Managing agent" + hint_text: "" + question_text: "Which organisation manages this letting?" + + assigned_to_id: + page_header: "" + check_answer_label: "Log owner" + hint_text: "" + question_text: "Which user are you creating this log for?" + + needstype: + page_header: "" + check_answer_label: "Needs type" + hint_text: "General needs housing includes both self-contained and shared housing without support or specific adaptations. Supported housing can include direct access hostels, group homes, residential care and nursing homes." + question_text: "What is the needs type?" + + scheme_id: + page_header: "Scheme" + check_answer_label: "Scheme name" + hint_text: "Enter postcode or scheme name" + question_text: "What scheme is this log for?" + + location_id: + less_than_twenty: + page_header: "Location" + check_answer_label: "Location" + hint_text: "" + question_text: "Which location is this letting for?" + twenty_or_more: + page_header: "Location" + check_answer_label: "Location" + hint_text: '
This scheme has 20 or more locations.
Enter postcode or address.' + question_text: "Which location is this letting for?" + + renewal: + page_header: "" + check_answer_label: "Property renewal" + hint_text: "A renewal is a letting to the same tenant in the same property. If the property was previously being used as temporary accommodation, then answer 'no'." + question_text: "Is this letting a renewal?" + + startdate: + page_header: "" + check_answer_label: "Tenancy start date" + hint_text: "" + question_text: "What is the tenancy start date?" + + rent_type: + page_header: "Rent Type" + rent_type: + check_answer_label: "Rent type" + hint_text: "" + question_text: "What is the rent type?" + irproduct_other: + check_answer_label: "Product name" + hint_text: "" + question_text: "Name of rent product" + + tenancycode: + page_header: "" + check_answer_label: "Tenant code" + hint_text: "This is how you usually refer to this tenancy on your own systems." + question_text: "What is the tenant code?" + + propcode: + page_header: "" + check_answer_label: "Property reference" + hint_text: "This is how you usually refer to this property on your own systems." + question_text: "What is the property reference?" diff --git a/config/locales/forms/2024/lettings/setup.en.yml b/config/locales/forms/2024/lettings/setup.en.yml new file mode 100644 index 000000000..5a18fe719 --- /dev/null +++ b/config/locales/forms/2024/lettings/setup.en.yml @@ -0,0 +1,87 @@ +en: + forms: + 2024: + lettings: + setup: + owning_organisation_id: + page_header: "" + check_answer_label: "Stock owner" + hint_text: "" + question_text: "Which organisation owns this property?" + + managing_organisation_id: + page_header: "" + check_answer_label: "Managing agent" + hint_text: "" + question_text: "Which organisation manages this letting?" + + assigned_to_id: + page_header: "" + check_answer_label: "Log owner" + hint_text: "" + question_text: "Which user are you creating this log for?" + + needstype: + page_header: "" + check_answer_label: "Needs type" + hint_text: "General needs housing includes both self-contained and shared housing without support or specific adaptations. Supported housing can include direct access hostels, group homes, residential care and nursing homes." + question_text: "What is the needs type?" + + scheme_id: + page_header: "Scheme" + check_answer_label: "Scheme name" + hint_text: "Enter postcode or scheme name.

A supported housing scheme provides shared or self-contained housing for a particular client group, for example younger or vulnerable people." + question_text: "What scheme is this log for?" + + location_id: + less_than_twenty: + page_header: "Location" + check_answer_label: "Location" + hint_text: "" + question_text: "Which location is this letting for?" + twenty_or_more: + page_header: "Location" + check_answer_label: "Location" + hint_text: '
This scheme has 20 or more locations.
Enter postcode or address.' + question_text: "Which location is this letting for?" + + renewal: + page_header: "" + check_answer_label: "Property renewal" + hint_text: "If the property was previously being used as temporary accommodation, then answer 'no'." + question_text: "Is this letting a renewal of social housing to the same tenant in the same property?" + + startdate: + page_header: "" + check_answer_label: "Tenancy start date" + hint_text: "" + question_text: "What is the tenancy start date?" + + rent_type: + page_header: "Rent Type" + rent_type: + check_answer_label: "Rent type" + hint_text: "" + question_text: "What is the rent type?" + irproduct_other: + check_answer_label: "Product name" + hint_text: "" + question_text: "Name of rent product" + + tenancycode: + page_header: "" + check_answer_label: "Tenant code" + hint_text: "This is how you usually refer to this tenancy on your own systems." + question_text: "What is the tenant code?" + + propcode: + page_header: "" + check_answer_label: "Property reference" + hint_text: "This is how you usually refer to this property on your own systems." + question_text: "What is the property reference?" + + declaration: + page_header: "Ministry of Housing, Communities and Local Government privacy notice" + check_answer_label: "Tenant has seen the privacy notice" + hint_text: "" + question_text: "Declaration" diff --git a/spec/features/form/check_answers_page_lettings_logs_spec.rb b/spec/features/form/check_answers_page_lettings_logs_spec.rb index d435f8b7a..bbbeccbe6 100644 --- a/spec/features/form/check_answers_page_lettings_logs_spec.rb +++ b/spec/features/form/check_answers_page_lettings_logs_spec.rb @@ -167,14 +167,12 @@ RSpec.describe "Lettings Log Check Answers Page" do it "displays inferred postcode with the location id" do lettings_log.update!(location:) visit("/lettings-logs/#{id}/setup/check-answers") - expect(page).to have_content("Location") expect(page).to have_content(location.name) end it "displays inferred postcode with the location_admin_district" do lettings_log.update!(location:) visit("/lettings-logs/#{id}/setup/check-answers") - expect(page).to have_content("Location") expect(page).to have_content(location.location_admin_district) end end diff --git a/spec/features/lettings_log_spec.rb b/spec/features/lettings_log_spec.rb index 218850992..092ab2b40 100644 --- a/spec/features/lettings_log_spec.rb +++ b/spec/features/lettings_log_spec.rb @@ -243,7 +243,7 @@ RSpec.describe "Lettings Log Features" do context "when completing the setup lettings log section", :aggregate_failure do before do - Timecop.freeze(Time.zone.local(2023, 3, 3)) + Timecop.freeze(Time.zone.local(2023, 4, 3)) Singleton.__init__(FormHandler) end diff --git a/spec/requests/form_controller_spec.rb b/spec/requests/form_controller_spec.rb index 80157e992..94f6595c7 100644 --- a/spec/requests/form_controller_spec.rb +++ b/spec/requests/form_controller_spec.rb @@ -735,14 +735,19 @@ RSpec.describe FormController, type: :request do end before do + Timecop.freeze(Time.zone.local(2023, 12, 1)) organisation.stock_owners << stock_owner organisation.managing_agents << managing_organisation organisation.managing_agents << managing_organisation_too organisation.reload - lettings_log.update!(owning_organisation: stock_owner, assigned_to: user, managing_organisation: organisation) + lettings_log.update!(owning_organisation: stock_owner, assigned_to: user, managing_organisation: organisation, startdate: Time.zone.local(2023, 5, 1)) lettings_log.reload end + after do + Timecop.unfreeze + end + it "re-renders the same page with errors if validation fails" do post "/lettings-logs/#{lettings_log.id}/managing-organisation", params: params expect(page).to have_content("There is a problem") diff --git a/spec/requests/lettings_logs_controller_spec.rb b/spec/requests/lettings_logs_controller_spec.rb index 6af9f3f12..308b90c1e 100644 --- a/spec/requests/lettings_logs_controller_spec.rb +++ b/spec/requests/lettings_logs_controller_spec.rb @@ -1538,7 +1538,7 @@ RSpec.describe LettingsLogsController, type: :request do end context "when viewing a specific log affected by deactivated location" do - let!(:affected_lettings_log) { FactoryBot.create(:lettings_log, unresolved: true, assigned_to: user, needstype: 2) } + let!(:affected_lettings_log) { FactoryBot.create(:lettings_log, unresolved: true, assigned_to: user, needstype: 2, startdate: Time.zone.local(2024, 4, 1)) } let(:headers) { { "Accept" => "text/html" } } before do