Browse Source

CLDC-2148-household-count-validation (#1452)

* alter har dmax value for number of other people in the property, change a couple of depends on formulations to improve readability

* correct linting error
pull/1459/head
Arthur Campbell 2 years ago committed by GitHub
parent
commit
2edb63d593
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 6
      app/models/form/sales/pages/number_of_others_in_property.rb
  2. 4
      app/models/form/sales/questions/number_of_others_in_property.rb
  3. 12
      spec/models/form/sales/pages/number_of_others_in_property_spec.rb
  4. 12
      spec/models/form/sales/questions/number_of_others_in_property_spec.rb

6
app/models/form/sales/pages/number_of_others_in_property.rb

@ -4,11 +4,11 @@ class Form::Sales::Pages::NumberOfOthersInProperty < ::Form::Page
@depends_on = [ @depends_on = [
{ {
"privacynotice" => 1, "privacynotice" => 1,
"jointpur" => joint_purchase ? 1 : 2, "joint_purchase?" => joint_purchase,
}, },
{ {
"noint" => 1, "buyer_not_interviewed?" => true,
"jointpur" => joint_purchase ? 1 : 2, "joint_purchase?" => joint_purchase,
}, },
] ]
@joint_purchase = joint_purchase @joint_purchase = joint_purchase

4
app/models/form/sales/questions/number_of_others_in_property.rb

@ -3,12 +3,12 @@ class Form::Sales::Questions::NumberOfOthersInProperty < ::Form::Question
super(id, hsh, page) super(id, hsh, page)
@id = "hholdcount" @id = "hholdcount"
@check_answer_label = "Number of other people living in the property" @check_answer_label = "Number of other people living in the property"
@header = "Besides the buyer(s), how many other people live or will live in the property?" @header = "Besides the #{'buyer'.pluralize(joint_purchase ? 2 : 1)}, how many other people live or will live in the property?"
@type = "numeric" @type = "numeric"
@hint_text = hint(joint_purchase) @hint_text = hint(joint_purchase)
@width = 2 @width = 2
@min = 0 @min = 0
@max = joint_purchase ? 4 : 5 @max = 15
@question_number = 35 @question_number = 35
end end

12
spec/models/form/sales/pages/number_of_others_in_property_spec.rb

@ -32,11 +32,11 @@ RSpec.describe Form::Sales::Pages::NumberOfOthersInProperty, type: :model do
expect(page.depends_on).to eq([ expect(page.depends_on).to eq([
{ {
"privacynotice" => 1, "privacynotice" => 1,
"jointpur" => 2, "joint_purchase?" => joint_purchase,
}, },
{ {
"noint" => 1, "buyer_not_interviewed?" => true,
"jointpur" => 2, "joint_purchase?" => joint_purchase,
}, },
]) ])
end end
@ -53,11 +53,11 @@ RSpec.describe Form::Sales::Pages::NumberOfOthersInProperty, type: :model do
expect(page.depends_on).to eq([ expect(page.depends_on).to eq([
{ {
"privacynotice" => 1, "privacynotice" => 1,
"jointpur" => 1, "joint_purchase?" => joint_purchase,
}, },
{ {
"noint" => 1, "buyer_not_interviewed?" => true,
"jointpur" => 1, "joint_purchase?" => joint_purchase,
}, },
]) ])
end end

12
spec/models/form/sales/questions/number_of_others_in_property_spec.rb

@ -9,7 +9,7 @@ RSpec.describe Form::Sales::Questions::NumberOfOthersInProperty, type: :model do
let(:joint_purchase) { true } let(:joint_purchase) { true }
it "has correct page" do it "has correct page" do
expect(question.page).to eq(page) expect(question.page).to be(page)
end end
it "has the correct id" do it "has the correct id" do
@ -17,7 +17,7 @@ RSpec.describe Form::Sales::Questions::NumberOfOthersInProperty, type: :model do
end end
it "has the correct header" do it "has the correct header" do
expect(question.header).to eq("Besides the buyer(s), how many other people live or will live in the property?") expect(question.header).to eq("Besides the buyers, how many other people live or will live in the property?")
end end
it "has the correct check_answer_label" do it "has the correct check_answer_label" do
@ -37,11 +37,11 @@ RSpec.describe Form::Sales::Questions::NumberOfOthersInProperty, type: :model do
end end
it "has the correct min" do it "has the correct min" do
expect(question.min).to eq(0) expect(question.min).to be 0
end end
it "has the correct max" do it "has the correct max" do
expect(question.max).to eq(4) expect(question.max).to be 15
end end
context "with non joint purchase" do context "with non joint purchase" do
@ -51,8 +51,8 @@ RSpec.describe Form::Sales::Questions::NumberOfOthersInProperty, type: :model do
expect(question.hint_text).to eq("You can provide details for a maximum of 5 other people if there is only one buyer.") expect(question.hint_text).to eq("You can provide details for a maximum of 5 other people if there is only one buyer.")
end end
it "has the correct max" do it "has the correct header" do
expect(question.max).to eq(5) expect(question.header).to eq("Besides the buyer, how many other people live or will live in the property?")
end end
end end
end end

Loading…
Cancel
Save