From c7c6ba9e074d0a7381e7c2b8e839d341abb53df6 Mon Sep 17 00:00:00 2001 From: Arthur Campbell Date: Mon, 27 Feb 2023 11:24:16 +0000 Subject: [PATCH] update options for shared ownership type for 23_24 various minor copy changes reordering one new option update tests to reflect this change --- .../sales/questions/shared_ownership_type.rb | 13 +++++- .../sales/pages/shared_ownership_type_spec.rb | 4 +- .../questions/shared_ownership_type_spec.rb | 44 ++++++++++++++----- 3 files changed, 48 insertions(+), 13 deletions(-) diff --git a/app/models/form/sales/questions/shared_ownership_type.rb b/app/models/form/sales/questions/shared_ownership_type.rb index 6351cc185..f128f857a 100644 --- a/app/models/form/sales/questions/shared_ownership_type.rb +++ b/app/models/form/sales/questions/shared_ownership_type.rb @@ -6,7 +6,7 @@ class Form::Sales::Questions::SharedOwnershipType < ::Form::Question @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" @type = "radio" - @answer_options = ANSWER_OPTIONS + @answer_options = form.start_date.year >= 2023 ? ANSWER_OPTIONS_23_24 : ANSWER_OPTIONS end ANSWER_OPTIONS = { @@ -18,4 +18,15 @@ class Form::Sales::Questions::SharedOwnershipType < ::Form::Question "31" => { "value" => "Right to Shared Ownership" }, "30" => { "value" => "Shared Ownership - 2021 model lease" }, }.freeze + + ANSWER_OPTIONS_23_24 = { + "2" => { "value" => "Shared Ownership (old model lease)" }, + "30" => { "value" => "Shared Ownership (new model lease)" }, + "18" => { "value" => "Social HomeBuy — shared ownership purchase" }, + "16" => { "value" => "Home Ownership for people with Long Term Disabilities (HOLD)" }, + "24" => { "value" => "Older Persons Shared Ownership" }, + "28" => { "value" => "Rent to Buy — Shared Ownership" }, + "31" => { "value" => "Right to Shared Ownership (RtSO)" }, + "32" => { "value" => "London Living Rent — Shared Ownership" }, + }.freeze 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 b8b71080f..09c277766 100644 --- a/spec/models/form/sales/pages/shared_ownership_type_spec.rb +++ b/spec/models/form/sales/pages/shared_ownership_type_spec.rb @@ -5,7 +5,9 @@ RSpec.describe Form::Sales::Pages::SharedOwnershipType, type: :model do let(:page_id) { nil } let(:page_definition) { nil } - let(:subsection) { instance_double(Form::Subsection) } + let(:start_date) { Time.utc(2022, 4, 1) } + let(:form) { instance_double(Form, start_date:) } + let(:subsection) { instance_double(Form::Subsection, form:) } it "has correct subsection" do expect(page.subsection).to eq(subsection) 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 c164c5794..e92311b55 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,10 @@ RSpec.describe Form::Sales::Questions::SharedOwnershipType, type: :model do let(:question_id) { nil } let(:question_definition) { nil } - let(:page) { instance_double(Form::Page) } + let(:start_date) { Time.utc(2022, 4, 1) } + let(:form) { instance_double(Form, start_date:) } + let(:subsection) { instance_double(Form::Subsection, form:) } + let(:page) { instance_double(Form::Page, subsection:) } it "has correct page" do expect(question.page).to eq(page) @@ -35,15 +38,34 @@ 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 - it "has the correct answer_options" do - expect(question.answer_options).to eq({ - "2" => { "value" => "Shared Ownership" }, - "24" => { "value" => "Old Persons Shared Ownership" }, - "18" => { "value" => "Social HomeBuy (shared ownership purchase)" }, - "16" => { "value" => "Home Ownership for people with Long Term Disabilities (HOLD)" }, - "28" => { "value" => "Rent to Buy - Shared Ownership" }, - "31" => { "value" => "Right to Shared Ownership" }, - "30" => { "value" => "Shared Ownership - 2021 model lease" }, - }) + context "when form start date is 2022" do + it "has the correct answer_options" do + expect(question.answer_options).to eq({ + "2" => { "value" => "Shared Ownership" }, + "24" => { "value" => "Old Persons Shared Ownership" }, + "18" => { "value" => "Social HomeBuy (shared ownership purchase)" }, + "16" => { "value" => "Home Ownership for people with Long Term Disabilities (HOLD)" }, + "28" => { "value" => "Rent to Buy - Shared Ownership" }, + "31" => { "value" => "Right to Shared Ownership" }, + "30" => { "value" => "Shared Ownership - 2021 model lease" }, + }) + end + end + + context "when form start date is 2023" do + let(:start_date) { Time.utc(2023, 4, 2) } + + it "has the correct answer_options" do + expect(question.answer_options).to eq({ + "2" => { "value" => "Shared Ownership (old model lease)" }, + "30" => { "value" => "Shared Ownership (new model lease)" }, + "18" => { "value" => "Social HomeBuy — shared ownership purchase" }, + "16" => { "value" => "Home Ownership for people with Long Term Disabilities (HOLD)" }, + "24" => { "value" => "Older Persons Shared Ownership" }, + "28" => { "value" => "Rent to Buy — Shared Ownership" }, + "31" => { "value" => "Right to Shared Ownership (RtSO)" }, + "32" => { "value" => "London Living Rent — Shared Ownership" }, + }) + end end end