Browse Source

feat: add answer option and test (#2190)

pull/2195/head
natdeanlewissoftwire 11 months ago committed by GitHub
parent
commit
92769036bd
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 2
      app/models/form/sales/questions/mortgageused.rb
  2. 16
      spec/models/form/sales/questions/mortgageused_spec.rb

2
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
{

16
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" },

Loading…
Cancel
Save