Browse Source

CLDC-3679: Copy changes lettings setup questions (#2723)

pull/2699/head^2
Manny Dinssa 3 months ago committed by GitHub
parent
commit
247b7f212f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 1
      app/models/form/lettings/pages/declaration.rb
  2. 2
      app/models/form/lettings/pages/location.rb
  3. 2
      app/models/form/lettings/pages/location_search.rb
  4. 2
      app/models/form/lettings/pages/rent_type.rb
  5. 1
      app/models/form/lettings/pages/scheme.rb
  6. 2
      app/models/form/lettings/questions/created_by_id.rb
  7. 3
      app/models/form/lettings/questions/irproduct_other.rb
  8. 11
      app/models/form/lettings/questions/location_id.rb
  9. 12
      app/models/form/lettings/questions/location_id_search.rb
  10. 2
      app/models/form/lettings/questions/managing_organisation.rb
  11. 3
      app/models/form/lettings/questions/needs_type.rb
  12. 3
      app/models/form/lettings/questions/property_reference.rb
  13. 19
      app/models/form/lettings/questions/renewal.rb
  14. 3
      app/models/form/lettings/questions/rent_type.rb
  15. 11
      app/models/form/lettings/questions/scheme_id.rb
  16. 2
      app/models/form/lettings/questions/stock_owner.rb
  17. 2
      app/models/form/lettings/questions/tenancy_start_date.rb
  18. 3
      app/models/form/lettings/questions/tenant_code.rb
  19. 81
      config/locales/forms/2023/lettings/setup.en.yml
  20. 87
      config/locales/forms/2024/lettings/setup.en.yml
  21. 2
      spec/features/form/check_answers_page_lettings_logs_spec.rb
  22. 2
      spec/features/lettings_log_spec.rb
  23. 7
      spec/requests/form_controller_spec.rb
  24. 2
      spec/requests/lettings_logs_controller_spec.rb

1
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

2
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

2
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

2
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

1
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

2
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

3
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

11
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

12
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 = '<div class="govuk-inset-text">This scheme has 20 or more locations.</div>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

2
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?

3
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?

3
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?

19
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

3
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

11
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.<br><br>
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)

2
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?

2
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?

3
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?

81
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: '<div class="govuk-inset-text">This scheme has 20 or more locations.</div>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?"

87
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.<br><br>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: '<div class="govuk-inset-text">This scheme has 20 or more locations.</div>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"

2
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

2
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

7
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")

2
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

Loading…
Cancel
Save