Browse Source

update validation for non joint purchase

pull/1297/head
Kat 3 years ago
parent
commit
48fb2dd570
  1. 2
      app/models/form/sales/questions/number_of_others_in_property.rb
  2. 12
      spec/models/form/sales/questions/number_of_others_in_property_spec.rb

2
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." @hint_text = "You can provide details for a maximum of #{joint_purchase ? '4' : '5'} other people."
@width = 2 @width = 2
@min = 0 @min = 0
@max = 4 @max = joint_purchase ? 4 : 5
end end
end end

12
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.") expect(question.hint_text).to eq("You can provide details for a maximum of 4 other people.")
end 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 context "with non joint purchase" do
let(:joint_purchase) { false } let(:joint_purchase) { false }
it "has the correct hint" do it "has the correct hint" do
expect(question.hint_text).to eq("You can provide details for a maximum of 5 other people.") expect(question.hint_text).to eq("You can provide details for a maximum of 5 other people.")
end end
it "has the correct max" do
expect(question.max).to eq(5)
end
end end
end end

Loading…
Cancel
Save