Browse Source

CLDC-3355: Reorder rent types on 2024/5 forms (#2343)

show-and-tell-28-3-24
Robert Sullivan 9 months ago committed by GitHub
parent
commit
1d5d736f03
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 13
      app/models/form/lettings/questions/rent_type.rb
  2. 21
      app/views/form/guidance/_rent_type_definitions_2024.erb
  3. 8
      spec/models/form/lettings/pages/rent_type_spec.rb
  4. 45
      spec/models/form/lettings/questions/rent_type_spec.rb

13
app/models/form/lettings/questions/rent_type.rb

@ -5,8 +5,8 @@ class Form::Lettings::Questions::RentType < ::Form::Question
@check_answer_label = "Rent type"
@header = "What is the rent type?"
@type = "radio"
@top_guidance_partial = "rent_type_definitions"
@answer_options = ANSWER_OPTIONS
@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
@conditional_for = { "irproduct_other" => [5] }
@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
@ -20,5 +20,14 @@ class Form::Lettings::Questions::RentType < ::Form::Question
"5" => { "value" => "Other intermediate rent product" },
}.freeze
ANSWER_OPTIONS_2024 = {
"0" => { "value" => "Social Rent" },
"1" => { "value" => "Affordable Rent" },
"2" => { "value" => "London Affordable Rent" },
"3" => { "value" => "Rent to Buy" },
"4" => { "value" => "London Living Rent" },
"5" => { "value" => "Other intermediate rent product" },
}.freeze
QUESTION_NUMBER_FROM_YEAR = { 2023 => 6, 2024 => 8 }.freeze
end

21
app/views/form/guidance/_rent_type_definitions_2024.erb

@ -0,0 +1,21 @@
<%= govuk_details(summary_text: "Rent type definitions") do %>
<p class="govuk-body">
<b>Social Rent:</b> where target rents are determined through the national rent regime. This is sometimes also known as 'formula rent'.
</p>
<p class="govuk-body">
<b>Affordable Rent:</b> where up to 80% of market rent can be charged. A new supply agreement is signed with Homes England or the Greater London Authority (GLA).
</p>
<p class="govuk-body">
<b>London Affordable Rent:</b> a tenure of affordable housing available in London by the GLA. It is an affordable rent which must be set in accordance with the Regulator of Social Housing’s Affordable Rent guidance. The landlord of these homes must be registered with the Regulator of Social Housing. These are a type of Affordable Rent lettings.
</p>
<p class="govuk-body">
<b>Rent to Buy: </b> a discount of up to 20% market rent is charged for a single rental period for a minimum of 5 years. After that period, the tenant is offered first chance to purchase the property (either shared ownership or outright) at full market value. These are a type of Intermediate Rent lettings.
</p>
<p class="govuk-body">
<b>London Living Rent:</b> a tenure of affordable housing available in London by the GLA. It was introduced in Affordable Homes Programme 2016 to 2021. These are a type of Intermediate Rent lettings.
</p>
<p class="govuk-body">
<b>Other intermediate rent:</b> any other specific scheme where up to 80% of market rent can be charged. This includes schemes with reduced rent so tenants can save towards a house purchasing deposit and schemes with an in-built future opportunity to buy the property being rented.
</p>
<% end %>

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

@ -5,7 +5,13 @@ RSpec.describe Form::Lettings::Pages::RentType, type: :model do
let(:page_id) { nil }
let(:page_definition) { nil }
let(:subsection) { instance_double(Form::Subsection, form: instance_double(Form, start_date: Time.zone.local(2024, 4, 1))) }
let(:subsection) { instance_double(Form::Subsection) }
let(:form) { instance_double(Form, start_date: Time.zone.local(2024, 4, 1)) }
before do
allow(subsection).to receive(:form).and_return(form)
allow(form).to receive(:start_year_after_2024?).and_return(true)
end
it "has correct subsection" do
expect(page.subsection).to eq(subsection)

45
spec/models/form/lettings/questions/rent_type_spec.rb

@ -5,7 +5,15 @@ RSpec.describe Form::Lettings::Questions::RentType, type: :model do
let(:question_id) { nil }
let(:question_definition) { nil }
let(:page) { instance_double(Form::Page, subsection: instance_double(Form::Subsection, form: instance_double(Form, start_date: Time.zone.local(2023, 4, 1)))) }
let(:page) { instance_double(Form::Page) }
let(:subsection) { instance_double(Form::Subsection) }
let(:form) { instance_double(Form, start_date: Time.zone.local(2023, 4, 1)) }
before do
allow(page).to receive(:subsection).and_return(subsection)
allow(subsection).to receive(:form).and_return(form)
allow(form).to receive(:start_year_after_2024?).and_return(false)
end
it "has correct page" do
expect(question.page).to eq(page)
@ -35,6 +43,15 @@ RSpec.describe Form::Lettings::Questions::RentType, type: :model do
expect(question.conditional_for).to eq({ "irproduct_other" => [5] })
end
it "is not marked as derived" do
expect(question.derived?).to be false
end
context "when 2023" do
before do
allow(form).to receive(:start_year_after_2024?).and_return(false)
end
it "has the correct answer_options" do
expect(question.answer_options).to eq({
"1" => { "value" => "Affordable Rent" },
@ -46,11 +63,29 @@ RSpec.describe Form::Lettings::Questions::RentType, type: :model do
})
end
it "is not marked as derived" do
expect(question.derived?).to be false
it "has the correct guidance partial" do
expect(question.top_guidance_partial).to eq("rent_type_definitions")
end
end
it "has the guidance partial" do
expect(question.top_guidance_partial).to eq("rent_type_definitions")
context "when 2024" do
before do
allow(form).to receive(:start_year_after_2024?).and_return(true)
end
it "has the correct answer_options" do
expect(question.answer_options).to eq({
"0" => { "value" => "Social Rent" },
"1" => { "value" => "Affordable Rent" },
"2" => { "value" => "London Affordable Rent" },
"3" => { "value" => "Rent to Buy" },
"4" => { "value" => "London Living Rent" },
"5" => { "value" => "Other intermediate rent product" },
})
end
it "has the correct guidance partial" do
expect(question.top_guidance_partial).to eq("rent_type_definitions_2024")
end
end
end

Loading…
Cancel
Save