From 48fb2dd570e5f11064fa2c316b554d8baf172082 Mon Sep 17 00:00:00 2001 From: Kat Date: Tue, 14 Feb 2023 08:10:53 +0000 Subject: [PATCH] update validation for non joint purchase --- .../sales/questions/number_of_others_in_property.rb | 2 +- .../questions/number_of_others_in_property_spec.rb | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/app/models/form/sales/questions/number_of_others_in_property.rb b/app/models/form/sales/questions/number_of_others_in_property.rb index c168e7633..a588a8c8d 100644 --- a/app/models/form/sales/questions/number_of_others_in_property.rb +++ b/app/models/form/sales/questions/number_of_others_in_property.rb @@ -8,6 +8,6 @@ class Form::Sales::Questions::NumberOfOthersInProperty < ::Form::Question @hint_text = "You can provide details for a maximum of #{joint_purchase ? '4' : '5'} other people." @width = 2 @min = 0 - @max = 4 + @max = joint_purchase ? 4 : 5 end end diff --git a/spec/models/form/sales/questions/number_of_others_in_property_spec.rb b/spec/models/form/sales/questions/number_of_others_in_property_spec.rb index af3963c6e..92e41cff7 100644 --- a/spec/models/form/sales/questions/number_of_others_in_property_spec.rb +++ b/spec/models/form/sales/questions/number_of_others_in_property_spec.rb @@ -36,11 +36,23 @@ RSpec.describe Form::Sales::Questions::NumberOfOthersInProperty, type: :model do expect(question.hint_text).to eq("You can provide details for a maximum of 4 other people.") end + it "has the correct min" do + expect(question.min).to eq(0) + end + + it "has the correct max" do + expect(question.max).to eq(4) + end + context "with non joint purchase" do let(:joint_purchase) { false } it "has the correct hint" do expect(question.hint_text).to eq("You can provide details for a maximum of 5 other people.") end + + it "has the correct max" do + expect(question.max).to eq(5) + end end end