Browse Source

CLDC 2075: Hint details added to 3 question pages for year 2023 (#1707)

* CLDC-2075: details added to three question pages with tests updated

* CLDC-2075: guidance partial displaying depends on specific year

* CLDC-2075: Page and questions tests for each for all 3 questions

* CLDC-2075: Header content change on all 3 question pages

* CLDC-2075: linting fix

* CLDC-2075: fix failing subsection test

* CLDC-2075: date clarification in tests

* CLDC-2075: Linting
pull/1715/head^2
Aaron Spencer 2 years ago committed by GitHub
parent
commit
1cf67d79e0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 5
      app/models/form/sales/pages/discounted_ownership_type.rb
  2. 5
      app/models/form/sales/pages/outright_ownership_type.rb
  3. 5
      app/models/form/sales/pages/shared_ownership_type.rb
  4. 6
      app/models/form/sales/questions/discounted_ownership_type.rb
  5. 6
      app/models/form/sales/questions/outright_ownership_type.rb
  6. 6
      app/models/form/sales/questions/shared_ownership_type.rb
  7. 23
      app/views/form/guidance/_discounted_ownership_type_definitions.erb
  8. 8
      app/views/form/guidance/_outright_sale_type_definitions.erb
  9. 26
      app/views/form/guidance/_shared_ownership_type_definitions.erb
  10. 25
      spec/models/form/sales/pages/discounted_ownership_type_spec.rb
  11. 25
      spec/models/form/sales/pages/outright_ownership_type_spec.rb
  12. 25
      spec/models/form/sales/pages/shared_ownership_type_spec.rb
  13. 27
      spec/models/form/sales/questions/discounted_ownership_type_spec.rb
  14. 35
      spec/models/form/sales/questions/outright_ownership_type_spec.rb
  15. 18
      spec/models/form/sales/questions/shared_ownership_type_spec.rb
  16. 3
      spec/models/form/sales/subsections/setup_spec.rb

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

@ -2,6 +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
@depends_on = [{ @depends_on = [{
"ownershipsch" => 2, "ownershipsch" => 2,
}] }]
@ -12,4 +13,8 @@ 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

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

@ -2,6 +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
@depends_on = [{ @depends_on = [{
"ownershipsch" => 3, "ownershipsch" => 3,
}] }]
@ -13,4 +14,8 @@ 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

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

@ -2,6 +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
@depends_on = [{ @depends_on = [{
"ownershipsch" => 1, "ownershipsch" => 1,
}] }]
@ -12,4 +13,8 @@ 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

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

@ -5,6 +5,8 @@ class Form::Sales::Questions::DiscountedOwnershipType < ::Form::Question
@check_answer_label = "Type of discounted ownership sale" @check_answer_label = "Type of discounted ownership sale"
@header = "What is the type of discounted ownership sale?" @header = "What is the type of discounted ownership sale?"
@type = "radio" @type = "radio"
@guidance_partial = guidance_partial
@guidance_position = GuidancePosition::TOP
@answer_options = ANSWER_OPTIONS @answer_options = ANSWER_OPTIONS
@question_number = 5 @question_number = 5
end end
@ -18,4 +20,8 @@ class Form::Sales::Questions::DiscountedOwnershipType < ::Form::Question
"21" => { "value" => "Social HomeBuy for outright purchase" }, "21" => { "value" => "Social HomeBuy for outright purchase" },
"22" => { "value" => "Any other equity loan scheme" }, "22" => { "value" => "Any other equity loan scheme" },
}.freeze }.freeze
def guidance_partial
"discounted_ownership_type_definitions" if form.start_date.year >= 2023
end
end end

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

@ -5,6 +5,8 @@ class Form::Sales::Questions::OutrightOwnershipType < ::Form::Question
@check_answer_label = "Type of outright sale" @check_answer_label = "Type of outright sale"
@header = "What is the type of outright sale?" @header = "What is the type of outright sale?"
@type = "radio" @type = "radio"
@guidance_partial = guidance_partial
@guidance_position = GuidancePosition::TOP
@answer_options = ANSWER_OPTIONS @answer_options = ANSWER_OPTIONS
@conditional_for = { @conditional_for = {
"othtype" => [12], "othtype" => [12],
@ -16,4 +18,8 @@ class Form::Sales::Questions::OutrightOwnershipType < ::Form::Question
"10" => { "value" => "Outright" }, "10" => { "value" => "Outright" },
"12" => { "value" => "Other sale" }, "12" => { "value" => "Other sale" },
}.freeze }.freeze
def guidance_partial
"outright_sale_type_definitions" if form.start_date.year >= 2023
end
end end

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

@ -5,6 +5,8 @@ class Form::Sales::Questions::SharedOwnershipType < ::Form::Question
@check_answer_label = "Type of shared ownership sale" @check_answer_label = "Type of shared ownership sale"
@header = "What is the type of shared ownership sale?" @header = "What is the 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" @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"
@guidance_partial = guidance_partial
@guidance_position = GuidancePosition::TOP
@type = "radio" @type = "radio"
@answer_options = answer_options @answer_options = answer_options
@question_number = 4 @question_number = 4
@ -34,4 +36,8 @@ class Form::Sales::Questions::SharedOwnershipType < ::Form::Question
} }
end end
end end
def guidance_partial
"shared_ownership_type_definitions" if form.start_date.year >= 2023
end
end end

23
app/views/form/guidance/_discounted_ownership_type_definitions.erb

@ -0,0 +1,23 @@
<%= govuk_details(summary_text: "Discounted ownership type definitions") do %>
<p class="govuk-body">
<b>Right to Acquire (RTA):</b> a discounted sale of a property built or purchased after 31 March 1997 to tenants of a private registered provider.
</p>
<p class="govuk-body">
<b>Preserved Right to Buy (PRTB):</b> a discounted sale of a property that used to be owned by a council to tenants of a private registered provider.
</p>
<p class="govuk-body">
<b>Voluntary Right to Buy (VRTB):</b> a discounted sale to tenants in this PRP owned property, as part of a pilot scheme.
</p>
<p class="govuk-body">
<b>Right to Buy (RTB):</b> a discounted sale to tenants in this council owned property.
</p>
<p class="govuk-body">
<b>Rent to Buy full ownership:</b> a sale on full ownership terms following a period of discounted rent.
</p>
<p class="govuk-body">
<b>Social HomeBuy for outright purchase:</b> a discounted sale to tenants of a private registered provider on full ownership terms.
</p>
<p class="govuk-body">
<b>Any other equity loan scheme:</b> any scheme, not covered elsewhere, in which a loan is used to purchase equity.
</p>
<% end %>

8
app/views/form/guidance/_outright_sale_type_definitions.erb

@ -0,0 +1,8 @@
<%= govuk_details(summary_text: "Outright sale type definitions") do %>
<p class="govuk-body">
<b>Outright sale:</b> the full purchase of a property, usually with a mortgage or cash.
</p>
<p class="govuk-body">
<b>Other sale:</b> any sale which does not fit the criteria of any of the remaining options.
</p>
<% end %>

26
app/views/form/guidance/_shared_ownership_type_definitions.erb

@ -0,0 +1,26 @@
<%= govuk_details(summary_text: "Shared ownership type definitions") do %>
<p class="govuk-body">
<b>Shared ownership:</b> Cannot be used for homes funded through the Affordable Homes Programme 2021 to 2026. Use the 2021 model lease for these properties.
</p>
<p class="govuk-body">
<b>Shared ownership 2021 model lease:</b> Homes bought using the Affordable Homes Programme 2021 to 2026.
</p>
<p class="govuk-body">
<b>Older Persons Shared Ownership:</b> A type of shared ownership for those 55 years and over.
</p>
<p class="govuk-body">
<b>Social HomeBuy shared ownership purchase:</b> Tenants of private registered providers purchase their home at discount on Shared Ownership terms.
</p>
<p class="govuk-body">
<b>Home Ownership for people with Long-Term Disabilities (HOLD):</b> A shared ownership sale for those with long term disabilities.
</p>
<p class="govuk-body">
<b>Rent to Buy shared ownership:</b> A sale following a period of discounted rent.
</p>
<p class="govuk-body">
<b>Right to Shared Ownership:</b> A sale of a share of a rented home to a tenant using this scheme.
</p>
<p class="govuk-body">
<b>London Living Rent shared ownership:</b> A shared ownership sale following a period of discounted rent as part of the London Living Rent scheme.
</p>
<% end %>

25
spec/models/form/sales/pages/discounted_ownership_type_spec.rb

@ -5,7 +5,26 @@ RSpec.describe Form::Sales::Pages::DiscountedOwnershipType, type: :model do
let(:page_id) { nil } let(:page_id) { nil }
let(:page_definition) { nil } let(:page_definition) { nil }
let(:subsection) { instance_double(Form::Subsection) } let(:subsection) { instance_double(Form::Subsection, form: instance_double(Form, start_date:)) }
let(:start_date) { Time.zone.today }
describe "headers" do
context "when form year is for 2023/24" do
let(:start_date) { Time.zone.local(2023, 4, 8) }
it "has the correct header" do
expect(page.header).to eq("Type of discounted ownership sale")
end
end
context "when form year is for before 2023/24" do
let(:start_date) { Time.zone.local(2022, 2, 8) }
it "does not have a page header" do
expect(page.header).to eq(nil)
end
end
end
it "has correct subsection" do it "has correct subsection" do
expect(page.subsection).to eq(subsection) expect(page.subsection).to eq(subsection)
@ -19,10 +38,6 @@ RSpec.describe Form::Sales::Pages::DiscountedOwnershipType, type: :model do
expect(page.id).to eq("discounted_ownership_type") expect(page.id).to eq("discounted_ownership_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

25
spec/models/form/sales/pages/outright_ownership_type_spec.rb

@ -5,7 +5,8 @@ RSpec.describe Form::Sales::Pages::OutrightOwnershipType, type: :model do
let(:page_id) { nil } let(:page_id) { nil }
let(:page_definition) { nil } let(:page_definition) { nil }
let(:subsection) { instance_double(Form::Subsection) } let(:subsection) { instance_double(Form::Subsection, form: instance_double(Form, start_date:)) }
let(:start_date) { Time.zone.today }
it "has correct subsection" do it "has correct subsection" do
expect(page.subsection).to eq(subsection) expect(page.subsection).to eq(subsection)
@ -19,10 +20,6 @@ RSpec.describe Form::Sales::Pages::OutrightOwnershipType, type: :model do
expect(page.id).to eq("outright_ownership_type") expect(page.id).to eq("outright_ownership_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
@ -32,4 +29,22 @@ RSpec.describe Form::Sales::Pages::OutrightOwnershipType, type: :model do
"ownershipsch" => 3, "ownershipsch" => 3,
}]) }])
end end
describe "headers" do
context "when the form year is 2023/24" do
let(:start_date) { Time.zone.local(2023, 4, 8) }
it "has the correct header" do
expect(page.header).to eq("Type of outright sale")
end
end
context "when the form is before the year 2023/24" do
let(:start_date) { Time.zone.local(2022, 4, 8) }
it "does not have a page header" do
expect(page.header).to eq(nil)
end
end
end
end end

25
spec/models/form/sales/pages/shared_ownership_type_spec.rb

@ -5,9 +5,26 @@ RSpec.describe Form::Sales::Pages::SharedOwnershipType, type: :model do
let(:page_id) { nil } let(:page_id) { nil }
let(:page_definition) { nil } let(:page_definition) { nil }
let(:subsection) { instance_double(Form::Subsection, form: instance_double(Form, start_date:)) }
let(:start_date) { Time.utc(2022, 4, 1) } let(:start_date) { Time.utc(2022, 4, 1) }
let(:form) { instance_double(Form, start_date:) }
let(:subsection) { instance_double(Form::Subsection, form:) } describe "headers" do
context "when form is after the year 2023/24" do
let(:start_date) { Time.zone.local(2023, 4, 8) }
it "has the correct header" do
expect(page.header).to eq("Type of shared ownership sale")
end
end
context "when form is before the year 2023/24" do
let(:start_date) { Time.zone.local(2022, 2, 8) }
it "has the correct header" do
expect(page.header).to eq(nil)
end
end
end
it "has correct subsection" do it "has correct subsection" do
expect(page.subsection).to eq(subsection) expect(page.subsection).to eq(subsection)
@ -21,10 +38,6 @@ RSpec.describe Form::Sales::Pages::SharedOwnershipType, type: :model do
expect(page.id).to eq("shared_ownership_type") expect(page.id).to eq("shared_ownership_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

27
spec/models/form/sales/questions/discounted_ownership_type_spec.rb

@ -5,7 +5,9 @@ RSpec.describe Form::Sales::Questions::DiscountedOwnershipType, type: :model do
let(:question_id) { nil } let(:question_id) { nil }
let(:question_definition) { nil } let(:question_definition) { nil }
let(:page) { instance_double(Form::Page) } let(:page) { instance_double(Form::Page, subsection:) }
let(:subsection) { instance_double(Form::Subsection, form: instance_double(Form, start_date:)) }
let(:start_date) { Time.zone.today }
it "has correct page" do it "has correct page" do
expect(question.page).to eq(page) expect(question.page).to eq(page)
@ -42,4 +44,27 @@ RSpec.describe Form::Sales::Questions::DiscountedOwnershipType, type: :model do
"22" => { "value" => "Any other equity loan scheme" }, "22" => { "value" => "Any other equity loan scheme" },
}) })
end end
describe "partial guidance" do
context "when the form is for 2023/24" do
let(:start_date) { Time.zone.local(2023, 4, 8) }
it "shows shows correct guidance_partial" do
expect(question.guidance_partial).to eq("discounted_ownership_type_definitions")
end
it "is at the top" do
expect(question.top_guidance?).to eq(true)
expect(question.bottom_guidance?).to eq(false)
end
end
context "when the form is for before 2023/24" do
let(:start_date) { Time.zone.local(2022, 4, 8) }
it "does not show a guidance_partial" do
expect(question.guidance_partial).to eq(nil)
end
end
end
end end

35
spec/models/form/sales/questions/outright_ownership_type_spec.rb

@ -5,7 +5,9 @@ RSpec.describe Form::Sales::Questions::OutrightOwnershipType, type: :model do
let(:question_id) { nil } let(:question_id) { nil }
let(:question_definition) { nil } let(:question_definition) { nil }
let(:page) { instance_double(Form::Page) } let(:page) { instance_double(Form::Page, subsection:) }
let(:subsection) { instance_double(Form::Subsection, form: instance_double(Form, start_date:)) }
let(:start_date) { Time.zone.today }
it "has correct page" do it "has correct page" do
expect(question.page).to eq(page) expect(question.page).to eq(page)
@ -15,10 +17,6 @@ RSpec.describe Form::Sales::Questions::OutrightOwnershipType, type: :model do
expect(question.id).to eq("type") expect(question.id).to eq("type")
end end
it "has the correct header" do
expect(question.header).to eq("What is the type of outright sale?")
end
it "has the correct check_answer_label" do it "has the correct check_answer_label" do
expect(question.check_answer_label).to eq("Type of outright sale") expect(question.check_answer_label).to eq("Type of outright sale")
end end
@ -43,4 +41,31 @@ RSpec.describe Form::Sales::Questions::OutrightOwnershipType, type: :model do
"othtype" => [12], "othtype" => [12],
}) })
end end
it "has the correct header" do
expect(question.header).to eq("What is the type of outright sale?")
end
describe "partial guidance" do
context "when the form is for year 2023/24" do
let(:start_date) { Time.zone.local(2023, 4, 8) }
it "has the correct guidance_partial" do
expect(question.guidance_partial).to eq("outright_sale_type_definitions")
end
it "is at the top" do
expect(question.top_guidance?).to eq(true)
expect(question.bottom_guidance?).to eq(false)
end
end
context "when the form is for before year 2023/24" do
let(:start_date) { Time.zone.local(2022, 4, 8) }
it "does not display a guidance partial" do
expect(question.guidance_partial).to eq(nil)
end
end
end
end end

18
spec/models/form/sales/questions/shared_ownership_type_spec.rb

@ -5,7 +5,7 @@ RSpec.describe Form::Sales::Questions::SharedOwnershipType, type: :model do
let(:question_id) { nil } let(:question_id) { nil }
let(:question_definition) { nil } let(:question_definition) { nil }
let(:start_date) { Time.utc(2022, 4, 1) } let(:start_date) { Time.zone.local(2022, 4, 1) }
let(:form) { instance_double(Form, start_date:) } let(:form) { instance_double(Form, start_date:) }
let(:subsection) { instance_double(Form::Subsection, form:) } let(:subsection) { instance_double(Form::Subsection, form:) }
let(:page) { instance_double(Form::Page, subsection:) } let(:page) { instance_double(Form::Page, subsection:) }
@ -38,7 +38,9 @@ RSpec.describe Form::Sales::Questions::SharedOwnershipType, type: :model do
expect(question.hint_text).to eq("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") expect(question.hint_text).to eq("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
context "when form start date is 2022" do context "when form start date is 2022/23" do
let(:start_date) { Time.zone.local(2022, 4, 1) }
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({
"2" => { "value" => "Shared Ownership" }, "2" => { "value" => "Shared Ownership" },
@ -50,10 +52,14 @@ RSpec.describe Form::Sales::Questions::SharedOwnershipType, type: :model do
"30" => { "value" => "Shared Ownership - 2021 model lease" }, "30" => { "value" => "Shared Ownership - 2021 model lease" },
}) })
end end
it "does not show a guidance_partial" do
expect(question.guidance_partial).to eq(nil)
end
end end
context "when form start date is 2023" do context "when form start date is 2023/24" do
let(:start_date) { Time.utc(2023, 4, 2) } let(:start_date) { Time.zone.local(2023, 4, 2) }
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({
@ -67,5 +73,9 @@ RSpec.describe Form::Sales::Questions::SharedOwnershipType, type: :model do
"32" => { "value" => "London Living Rent — Shared Ownership" }, "32" => { "value" => "London Living Rent — Shared Ownership" },
}) })
end end
it "shows shows correct guidance_partial" do
expect(question.guidance_partial).to eq("shared_ownership_type_definitions")
end
end end
end end

3
spec/models/form/sales/subsections/setup_spec.rb

@ -5,7 +5,8 @@ RSpec.describe Form::Sales::Subsections::Setup, type: :model do
let(:subsection_id) { nil } let(:subsection_id) { nil }
let(:subsection_definition) { nil } let(:subsection_definition) { nil }
let(:section) { instance_double(Form::Sales::Sections::Setup) } let(:section) { instance_double(Form::Sales::Sections::Setup, form: instance_double(Form, start_date:)) }
let(:start_date) { Time.utc(2022, 4, 1) }
it "has correct section" do it "has correct section" do
expect(setup.section).to eq(section) expect(setup.section).to eq(section)

Loading…
Cancel
Save