From 00a9f1daa17ae626b6f57e8aa00e7c52486000ee Mon Sep 17 00:00:00 2001 From: samyou-softwire Date: Wed, 11 Mar 2026 09:45:42 +0000 Subject: [PATCH] fixup! CLDC-4215: Update tests cover all cases --- .../form/sales/questions/mortgageused_spec.rb | 58 ++++++++++++++----- 1 file changed, 44 insertions(+), 14 deletions(-) diff --git a/spec/models/form/sales/questions/mortgageused_spec.rb b/spec/models/form/sales/questions/mortgageused_spec.rb index bdf9ef4f8..65bd2d3cd 100644 --- a/spec/models/form/sales/questions/mortgageused_spec.rb +++ b/spec/models/form/sales/questions/mortgageused_spec.rb @@ -17,21 +17,35 @@ RSpec.describe Form::Sales::Questions::Mortgageused, type: :model do let(:form) { instance_double(Form, start_date: saledate, start_year_2024_or_later?: start_year_2024_or_later?, start_year_2025_or_later?: start_year_2025_or_later?, start_year_2026_or_later?: start_year_2026_or_later?) } let(:page) { instance_double(Form::Page, subsection: instance_double(Form::Subsection, form:, id: "shared_ownership")) } + context "when it is a shared ownership scheme" do + let(:ownershipsch) { 1 } + + it "has the correct top_guidance_partial" do + expect(question.top_guidance_partial).to eq("financial_calculations_shared_ownership") + end + end + + context "when it is a discounted ownership sale" do + let(:ownershipsch) { 2 } + + it "has the correct top_guidance_partial" do + expect(question.top_guidance_partial).to eq("financial_calculations_discounted_ownership") + end + end + + context "when it is an outright sale" do + let(:ownershipsch) { 3 } + + it "has the correct top_guidance_partial" do + expect(question.top_guidance_partial).to eq("financial_calculations_outright_sale") + end + end + context "when the form start year is 2024", metadata: { year: 24 } do let(:saledate) { collection_start_date_for_year(2024) } - let(:ownershipsch) { 1 } let(:start_year_2025_or_later?) { false } let(:start_year_2026_or_later?) { false } - it "has the correct answer_options" do - expect(question.answer_options).to eq({ - "1" => { "value" => "Yes" }, - "2" => { "value" => "No" }, - "divider" => { "value" => true }, - "3" => { "value" => "Don’t know" }, - }) - end - context "when it is a discounted ownership sale" do let(:ownershipsch) { 2 } @@ -47,6 +61,10 @@ RSpec.describe Form::Sales::Questions::Mortgageused, type: :model do context "when it is an outright sale" do let(:ownershipsch) { 3 } + it "shows the correct question number" do + expect(question.question_number).to eq 112 + end + it "shows the don't know option" do expect_the_question_to_show_dont_know end @@ -55,6 +73,10 @@ RSpec.describe Form::Sales::Questions::Mortgageused, type: :model do context "when it is a shared ownership scheme" do let(:ownershipsch) { 1 } + it "shows the correct question number" do + expect(question.question_number).to eq 91 + end + context "and it is a staircasing transaction" do let(:staircase) { 1 } @@ -104,10 +126,14 @@ RSpec.describe Form::Sales::Questions::Mortgageused, type: :model do context "when it is a shared ownership scheme" do let(:ownershipsch) { 1 } + it "shows the correct question number" do + expect(question.question_number).to eq 82 + end + context "and it is a staircasing transaction" do let(:staircase) { 1 } - it "does show the don't know option" do + it "shows the don't know option" do expect_the_question_to_show_dont_know end @@ -140,7 +166,7 @@ RSpec.describe Form::Sales::Questions::Mortgageused, type: :model do expect(question.question_number).to eq 106 end - it "does show the don't know option" do + it "shows the don't know option" do expect_the_question_to_show_dont_know end end @@ -148,10 +174,14 @@ RSpec.describe Form::Sales::Questions::Mortgageused, type: :model do context "when it is a shared ownership scheme" do let(:ownershipsch) { 1 } + it "shows the correct question number" do + expect(question.question_number).to eq 82 + end + context "and it is a staircasing transaction" do let(:staircase) { 1 } - it "does show the don't know option" do + it "shows the don't know option" do expect_the_question_to_show_dont_know end end @@ -159,7 +189,7 @@ RSpec.describe Form::Sales::Questions::Mortgageused, type: :model do context "and it is not a staircasing transaction" do let(:staircase) { 2 } - it "does show the don't know option" do + it "shows the don't know option" do expect_the_question_to_show_dont_know end end