diff --git a/app/models/form/sales/questions/shared_ownership_type.rb b/app/models/form/sales/questions/shared_ownership_type.rb index 6351cc185..73b6a4e17 100644 --- a/app/models/form/sales/questions/shared_ownership_type.rb +++ b/app/models/form/sales/questions/shared_ownership_type.rb @@ -6,16 +6,31 @@ 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 = answer_options end - ANSWER_OPTIONS = { - "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" }, - }.freeze + def answer_options + if form.start_date.year >= 2023 + { + "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" }, + } + else + { + "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 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..3f60155bf 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