From 92769036bd4c27d0c7c0bb214a5e6ecdf0b0e1e9 Mon Sep 17 00:00:00 2001 From: natdeanlewissoftwire <94526761+natdeanlewissoftwire@users.noreply.github.com> Date: Tue, 30 Jan 2024 17:16:25 +0000 Subject: [PATCH] feat: add answer option and test (#2190) --- app/models/form/sales/questions/mortgageused.rb | 2 +- .../form/sales/questions/mortgageused_spec.rb | 16 ++++++++++++++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/app/models/form/sales/questions/mortgageused.rb b/app/models/form/sales/questions/mortgageused.rb index e8f8d0e6b..ad7f31017 100644 --- a/app/models/form/sales/questions/mortgageused.rb +++ b/app/models/form/sales/questions/mortgageused.rb @@ -17,7 +17,7 @@ class Form::Sales::Questions::Mortgageused < ::Form::Question }.freeze def displayed_answer_options(log, _user = nil) - if log.stairowned == 100 + if log.stairowned == 100 || @ownershipsch == 3 ANSWER_OPTIONS else { diff --git a/spec/models/form/sales/questions/mortgageused_spec.rb b/spec/models/form/sales/questions/mortgageused_spec.rb index e423aaf80..60c51acd9 100644 --- a/spec/models/form/sales/questions/mortgageused_spec.rb +++ b/spec/models/form/sales/questions/mortgageused_spec.rb @@ -51,7 +51,19 @@ RSpec.describe Form::Sales::Questions::Mortgageused, type: :model do context "when staircase owned percentage is 100%" do let(:log) { build(:sales_log, stairowned: 100) } - it "show's the don't know option" do + it "shows the don't know option" do + expect(question.displayed_answer_options(log)).to eq({ + "1" => { "value" => "Yes" }, + "2" => { "value" => "No" }, + "3" => { "value" => "Don’t know" }, + }) + end + end + + context "when an outright sale" do + subject(:question) { described_class.new(question_id, question_definition, page, ownershipsch: 3) } + + it "shows the don't know option" do expect(question.displayed_answer_options(log)).to eq({ "1" => { "value" => "Yes" }, "2" => { "value" => "No" }, @@ -63,7 +75,7 @@ RSpec.describe Form::Sales::Questions::Mortgageused, type: :model do context "when staircase owned percentage is less than 100%" do let(:log) { build(:sales_log, stairowned: 99) } - it "show's the don't know option" do + it "shows the don't know option" do expect(question.displayed_answer_options(log)).to eq({ "1" => { "value" => "Yes" }, "2" => { "value" => "No" },