From 1cf67d79e0d53068ebd0bcd76f5b835d7c638903 Mon Sep 17 00:00:00 2001 From: Aaron Spencer <62190777+Airk0n@users.noreply.github.com> Date: Wed, 21 Jun 2023 11:45:05 +0100 Subject: [PATCH] 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 --- .../sales/pages/discounted_ownership_type.rb | 5 +++ .../sales/pages/outright_ownership_type.rb | 5 +++ .../form/sales/pages/shared_ownership_type.rb | 5 +++ .../questions/discounted_ownership_type.rb | 6 ++++ .../questions/outright_ownership_type.rb | 6 ++++ .../sales/questions/shared_ownership_type.rb | 6 ++++ ..._discounted_ownership_type_definitions.erb | 23 ++++++++++++ .../_outright_sale_type_definitions.erb | 8 +++++ .../_shared_ownership_type_definitions.erb | 26 ++++++++++++++ .../pages/discounted_ownership_type_spec.rb | 25 ++++++++++--- .../pages/outright_ownership_type_spec.rb | 25 ++++++++++--- .../sales/pages/shared_ownership_type_spec.rb | 25 +++++++++---- .../discounted_ownership_type_spec.rb | 27 +++++++++++++- .../questions/outright_ownership_type_spec.rb | 35 ++++++++++++++++--- .../questions/shared_ownership_type_spec.rb | 18 +++++++--- .../form/sales/subsections/setup_spec.rb | 3 +- 16 files changed, 221 insertions(+), 27 deletions(-) create mode 100644 app/views/form/guidance/_discounted_ownership_type_definitions.erb create mode 100644 app/views/form/guidance/_outright_sale_type_definitions.erb create mode 100644 app/views/form/guidance/_shared_ownership_type_definitions.erb diff --git a/app/models/form/sales/pages/discounted_ownership_type.rb b/app/models/form/sales/pages/discounted_ownership_type.rb index 4c7ae2464..3fe2011ef 100644 --- a/app/models/form/sales/pages/discounted_ownership_type.rb +++ b/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) super @id = "discounted_ownership_type" + @header = header @depends_on = [{ "ownershipsch" => 2, }] @@ -12,4 +13,8 @@ class Form::Sales::Pages::DiscountedOwnershipType < ::Form::Page Form::Sales::Questions::DiscountedOwnershipType.new(nil, nil, self), ] end + + def header + "Type of discounted ownership sale" if form.start_date.year >= 2023 + end end diff --git a/app/models/form/sales/pages/outright_ownership_type.rb b/app/models/form/sales/pages/outright_ownership_type.rb index 3fc5ff115..099b45d07 100644 --- a/app/models/form/sales/pages/outright_ownership_type.rb +++ b/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) super @id = "outright_ownership_type" + @header = header @depends_on = [{ "ownershipsch" => 3, }] @@ -13,4 +14,8 @@ class Form::Sales::Pages::OutrightOwnershipType < ::Form::Page Form::Sales::Questions::OtherOwnershipType.new(nil, nil, self), ] end + + def header + "Type of outright sale" if form.start_date.year >= 2023 + end end diff --git a/app/models/form/sales/pages/shared_ownership_type.rb b/app/models/form/sales/pages/shared_ownership_type.rb index 3bc5dbdf7..3e65cb628 100644 --- a/app/models/form/sales/pages/shared_ownership_type.rb +++ b/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) super @id = "shared_ownership_type" + @header = header @depends_on = [{ "ownershipsch" => 1, }] @@ -12,4 +13,8 @@ class Form::Sales::Pages::SharedOwnershipType < ::Form::Page Form::Sales::Questions::SharedOwnershipType.new(nil, nil, self), ] end + + def header + "Type of shared ownership sale" if form.start_date.year >= 2023 + end end diff --git a/app/models/form/sales/questions/discounted_ownership_type.rb b/app/models/form/sales/questions/discounted_ownership_type.rb index 99e10b1db..aeb00fac1 100644 --- a/app/models/form/sales/questions/discounted_ownership_type.rb +++ b/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" @header = "What is the type of discounted ownership sale?" @type = "radio" + @guidance_partial = guidance_partial + @guidance_position = GuidancePosition::TOP @answer_options = ANSWER_OPTIONS @question_number = 5 end @@ -18,4 +20,8 @@ class Form::Sales::Questions::DiscountedOwnershipType < ::Form::Question "21" => { "value" => "Social HomeBuy for outright purchase" }, "22" => { "value" => "Any other equity loan scheme" }, }.freeze + + def guidance_partial + "discounted_ownership_type_definitions" if form.start_date.year >= 2023 + end end diff --git a/app/models/form/sales/questions/outright_ownership_type.rb b/app/models/form/sales/questions/outright_ownership_type.rb index 01fa77a0d..71fa86e65 100644 --- a/app/models/form/sales/questions/outright_ownership_type.rb +++ b/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" @header = "What is the type of outright sale?" @type = "radio" + @guidance_partial = guidance_partial + @guidance_position = GuidancePosition::TOP @answer_options = ANSWER_OPTIONS @conditional_for = { "othtype" => [12], @@ -16,4 +18,8 @@ class Form::Sales::Questions::OutrightOwnershipType < ::Form::Question "10" => { "value" => "Outright" }, "12" => { "value" => "Other sale" }, }.freeze + + def guidance_partial + "outright_sale_type_definitions" if form.start_date.year >= 2023 + end end diff --git a/app/models/form/sales/questions/shared_ownership_type.rb b/app/models/form/sales/questions/shared_ownership_type.rb index e0cb5b486..053af2e1a 100644 --- a/app/models/form/sales/questions/shared_ownership_type.rb +++ b/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" @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" + @guidance_partial = guidance_partial + @guidance_position = GuidancePosition::TOP @type = "radio" @answer_options = answer_options @question_number = 4 @@ -34,4 +36,8 @@ class Form::Sales::Questions::SharedOwnershipType < ::Form::Question } end end + + def guidance_partial + "shared_ownership_type_definitions" if form.start_date.year >= 2023 + end end diff --git a/app/views/form/guidance/_discounted_ownership_type_definitions.erb b/app/views/form/guidance/_discounted_ownership_type_definitions.erb new file mode 100644 index 000000000..0102a836a --- /dev/null +++ b/app/views/form/guidance/_discounted_ownership_type_definitions.erb @@ -0,0 +1,23 @@ +<%= govuk_details(summary_text: "Discounted ownership type definitions") do %> +
+ Right to Acquire (RTA): a discounted sale of a property built or purchased after 31 March 1997 to tenants of a private registered provider. +
++ Preserved Right to Buy (PRTB): a discounted sale of a property that used to be owned by a council to tenants of a private registered provider. +
++ Voluntary Right to Buy (VRTB): a discounted sale to tenants in this PRP owned property, as part of a pilot scheme. +
++ Right to Buy (RTB): a discounted sale to tenants in this council owned property. +
++ Rent to Buy full ownership: a sale on full ownership terms following a period of discounted rent. +
++ Social HomeBuy for outright purchase: a discounted sale to tenants of a private registered provider on full ownership terms. +
++ Any other equity loan scheme: any scheme, not covered elsewhere, in which a loan is used to purchase equity. +
+<% end %> diff --git a/app/views/form/guidance/_outright_sale_type_definitions.erb b/app/views/form/guidance/_outright_sale_type_definitions.erb new file mode 100644 index 000000000..01e5253d0 --- /dev/null +++ b/app/views/form/guidance/_outright_sale_type_definitions.erb @@ -0,0 +1,8 @@ +<%= govuk_details(summary_text: "Outright sale type definitions") do %> ++ Outright sale: the full purchase of a property, usually with a mortgage or cash. +
++ Other sale: any sale which does not fit the criteria of any of the remaining options. +
+<% end %> diff --git a/app/views/form/guidance/_shared_ownership_type_definitions.erb b/app/views/form/guidance/_shared_ownership_type_definitions.erb new file mode 100644 index 000000000..95cd65533 --- /dev/null +++ b/app/views/form/guidance/_shared_ownership_type_definitions.erb @@ -0,0 +1,26 @@ +<%= govuk_details(summary_text: "Shared ownership type definitions") do %> ++ Shared ownership: Cannot be used for homes funded through the Affordable Homes Programme 2021 to 2026. Use the 2021 model lease for these properties. +
++ Shared ownership 2021 model lease: Homes bought using the Affordable Homes Programme 2021 to 2026. +
++ Older Persons Shared Ownership: A type of shared ownership for those 55 years and over. +
++ Social HomeBuy shared ownership purchase: Tenants of private registered providers purchase their home at discount on Shared Ownership terms. +
++ Home Ownership for people with Long-Term Disabilities (HOLD): A shared ownership sale for those with long term disabilities. +
++ Rent to Buy shared ownership: A sale following a period of discounted rent. +
++ Right to Shared Ownership: A sale of a share of a rented home to a tenant using this scheme. +
++ London Living Rent shared ownership: A shared ownership sale following a period of discounted rent as part of the London Living Rent scheme. +
+<% end %> diff --git a/spec/models/form/sales/pages/discounted_ownership_type_spec.rb b/spec/models/form/sales/pages/discounted_ownership_type_spec.rb index 8951e3323..708090420 100644 --- a/spec/models/form/sales/pages/discounted_ownership_type_spec.rb +++ b/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_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 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") end - it "has the correct header" do - expect(page.header).to be_nil - end - it "has the correct description" do expect(page.description).to be_nil end diff --git a/spec/models/form/sales/pages/outright_ownership_type_spec.rb b/spec/models/form/sales/pages/outright_ownership_type_spec.rb index 5ca515cc9..a080d148d 100644 --- a/spec/models/form/sales/pages/outright_ownership_type_spec.rb +++ b/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_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 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") end - it "has the correct header" do - expect(page.header).to be_nil - end - it "has the correct description" do expect(page.description).to be_nil end @@ -32,4 +29,22 @@ RSpec.describe Form::Sales::Pages::OutrightOwnershipType, type: :model do "ownershipsch" => 3, }]) 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 diff --git a/spec/models/form/sales/pages/shared_ownership_type_spec.rb b/spec/models/form/sales/pages/shared_ownership_type_spec.rb index 09c277766..dfed74fb3 100644 --- a/spec/models/form/sales/pages/shared_ownership_type_spec.rb +++ b/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_definition) { nil } + let(:subsection) { instance_double(Form::Subsection, form: instance_double(Form, start_date:)) } 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 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") end - it "has the correct header" do - expect(page.header).to be_nil - end - it "has the correct description" do expect(page.description).to be_nil end diff --git a/spec/models/form/sales/questions/discounted_ownership_type_spec.rb b/spec/models/form/sales/questions/discounted_ownership_type_spec.rb index d1c074023..766466e74 100644 --- a/spec/models/form/sales/questions/discounted_ownership_type_spec.rb +++ b/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_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 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" }, }) 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 diff --git a/spec/models/form/sales/questions/outright_ownership_type_spec.rb b/spec/models/form/sales/questions/outright_ownership_type_spec.rb index 69b499e52..42804f938 100644 --- a/spec/models/form/sales/questions/outright_ownership_type_spec.rb +++ b/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_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 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") 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 expect(question.check_answer_label).to eq("Type of outright sale") end @@ -43,4 +41,31 @@ RSpec.describe Form::Sales::Questions::OutrightOwnershipType, type: :model do "othtype" => [12], }) 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 diff --git a/spec/models/form/sales/questions/shared_ownership_type_spec.rb b/spec/models/form/sales/questions/shared_ownership_type_spec.rb index 3f60155bf..669acd9a6 100644 --- a/spec/models/form/sales/questions/shared_ownership_type_spec.rb +++ b/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_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(:subsection) { instance_double(Form::Subsection, form:) } 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") 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 expect(question.answer_options).to eq({ "2" => { "value" => "Shared Ownership" }, @@ -50,10 +52,14 @@ RSpec.describe Form::Sales::Questions::SharedOwnershipType, type: :model do "30" => { "value" => "Shared Ownership - 2021 model lease" }, }) end + + it "does not show a guidance_partial" do + expect(question.guidance_partial).to eq(nil) + end end - context "when form start date is 2023" do - let(:start_date) { Time.utc(2023, 4, 2) } + context "when form start date is 2023/24" do + let(:start_date) { Time.zone.local(2023, 4, 2) } it "has the correct answer_options" do 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" }, }) end + + it "shows shows correct guidance_partial" do + expect(question.guidance_partial).to eq("shared_ownership_type_definitions") + end end end diff --git a/spec/models/form/sales/subsections/setup_spec.rb b/spec/models/form/sales/subsections/setup_spec.rb index 36fbf247a..7a71e946c 100644 --- a/spec/models/form/sales/subsections/setup_spec.rb +++ b/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_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 expect(setup.section).to eq(section)