Browse Source

Route to pages when joint purchase is not answered

pull/2272/head
Kat 2 years ago
parent
commit
4003132489
  1. 2
      app/models/form/sales/pages/buyer_interview.rb
  2. 2
      app/models/form/sales/pages/deposit_value_check.rb
  3. 2
      app/models/form/sales/pages/housing_benefits.rb
  4. 2
      app/models/form/sales/pages/living_before_purchase.rb
  5. 3
      app/models/form/sales/pages/old_persons_shared_ownership_value_check.rb
  6. 2
      app/models/form/sales/pages/privacy_notice.rb
  7. 2
      app/models/form/sales/pages/savings.rb
  8. 3
      app/models/form/sales/pages/savings_value_check.rb
  9. 4
      spec/models/form/sales/pages/deposit_value_check_spec.rb
  10. 2
      spec/models/form/sales/pages/housing_benefits_spec.rb
  11. 2
      spec/models/form/sales/pages/living_before_purchase_spec.rb
  12. 4
      spec/models/form/sales/pages/old_persons_shared_ownership_value_check_spec.rb
  13. 2
      spec/models/form/sales/pages/privacy_notice_spec.rb
  14. 2
      spec/models/form/sales/pages/savings_spec.rb
  15. 2
      spec/models/form/sales/pages/savings_value_check_spec.rb
  16. 9
      spec/models/validations/shared_validations_spec.rb

2
app/models/form/sales/pages/buyer_interview.rb

@ -14,7 +14,7 @@ class Form::Sales::Pages::BuyerInterview < ::Form::Page
if @joint_purchase if @joint_purchase
[{ "joint_purchase?" => true }] [{ "joint_purchase?" => true }]
else else
[{ "not_joint_purchase?" => true }] [{ "not_joint_purchase?" => true }, { "jointpur" => nil }]
end end
end end
end end

2
app/models/form/sales/pages/deposit_value_check.rb

@ -37,7 +37,7 @@ class Form::Sales::Pages::DepositValueCheck < ::Form::Page
if @joint_purchase if @joint_purchase
[{ "joint_purchase?" => true, "deposit_over_soft_max?" => true }] [{ "joint_purchase?" => true, "deposit_over_soft_max?" => true }]
else else
[{ "not_joint_purchase?" => true, "deposit_over_soft_max?" => true }] [{ "not_joint_purchase?" => true, "deposit_over_soft_max?" => true }, { "jointpur" => nil, "deposit_over_soft_max?" => true }]
end end
end end
end end

2
app/models/form/sales/pages/housing_benefits.rb

@ -14,7 +14,7 @@ class Form::Sales::Pages::HousingBenefits < ::Form::Page
if @joint_purchase if @joint_purchase
[{ "joint_purchase?" => true }] [{ "joint_purchase?" => true }]
else else
[{ "not_joint_purchase?" => true }] [{ "not_joint_purchase?" => true }, { "jointpur" => nil }]
end end
end end
end end

2
app/models/form/sales/pages/living_before_purchase.rb

@ -22,7 +22,7 @@ class Form::Sales::Pages::LivingBeforePurchase < ::Form::Page
if @joint_purchase if @joint_purchase
[{ "joint_purchase?" => true }] [{ "joint_purchase?" => true }]
else else
[{ "not_joint_purchase?" => true }] [{ "not_joint_purchase?" => true }, { "jointpur" => nil }]
end end
end end
end end

3
app/models/form/sales/pages/old_persons_shared_ownership_value_check.rb

@ -26,7 +26,8 @@ class Form::Sales::Pages::OldPersonsSharedOwnershipValueCheck < ::Form::Page
if @joint_purchase if @joint_purchase
[{ "joint_purchase?" => true, "buyers_age_for_old_persons_shared_ownership_invalid?" => true }] [{ "joint_purchase?" => true, "buyers_age_for_old_persons_shared_ownership_invalid?" => true }]
else else
[{ "not_joint_purchase?" => true, "buyers_age_for_old_persons_shared_ownership_invalid?" => true }] [{ "not_joint_purchase?" => true, "buyers_age_for_old_persons_shared_ownership_invalid?" => true },
{ "jointpur" => nil, "buyers_age_for_old_persons_shared_ownership_invalid?" => true }]
end end
end end
end end

2
app/models/form/sales/pages/privacy_notice.rb

@ -15,7 +15,7 @@ class Form::Sales::Pages::PrivacyNotice < ::Form::Page
if @joint_purchase if @joint_purchase
[{ "joint_purchase?" => true }] [{ "joint_purchase?" => true }]
else else
[{ "not_joint_purchase?" => true }] [{ "not_joint_purchase?" => true }, { "jointpur" => nil }]
end end
end end
end end

2
app/models/form/sales/pages/savings.rb

@ -15,7 +15,7 @@ class Form::Sales::Pages::Savings < ::Form::Page
if @joint_purchase if @joint_purchase
[{ "joint_purchase?" => true }] [{ "joint_purchase?" => true }]
else else
[{ "not_joint_purchase?" => true }] [{ "not_joint_purchase?" => true }, { "jointpur" => nil }]
end end
end end
end end

3
app/models/form/sales/pages/savings_value_check.rb

@ -32,7 +32,8 @@ class Form::Sales::Pages::SavingsValueCheck < ::Form::Page
if @joint_purchase if @joint_purchase
[{ "joint_purchase?" => true, "savings_over_soft_max?" => true }] [{ "joint_purchase?" => true, "savings_over_soft_max?" => true }]
else else
[{ "not_joint_purchase?" => true, "savings_over_soft_max?" => true }] [{ "not_joint_purchase?" => true, "savings_over_soft_max?" => true },
{ "jointpur" => nil, "savings_over_soft_max?" => true }]
end end
end end
end end

4
spec/models/form/sales/pages/deposit_value_check_spec.rb

@ -29,6 +29,10 @@ RSpec.describe Form::Sales::Pages::DepositValueCheck, type: :model do
"deposit_over_soft_max?" => true, "deposit_over_soft_max?" => true,
"not_joint_purchase?" => true, "not_joint_purchase?" => true,
}, },
{
"deposit_over_soft_max?" => true,
"jointpur" => nil,
},
]) ])
end end

2
spec/models/form/sales/pages/housing_benefits_spec.rb

@ -30,7 +30,7 @@ RSpec.describe Form::Sales::Pages::HousingBenefits, type: :model do
context "when joint_purchase is false" do context "when joint_purchase is false" do
it "has correct depends_on" do it "has correct depends_on" do
expect(page.depends_on).to eq([{ "not_joint_purchase?" => true }]) expect(page.depends_on).to eq([{ "not_joint_purchase?" => true }, { "jointpur" => nil }])
end end
end end

2
spec/models/form/sales/pages/living_before_purchase_spec.rb

@ -44,7 +44,7 @@ RSpec.describe Form::Sales::Pages::LivingBeforePurchase, type: :model do
end end
it "has correct depends_on" do it "has correct depends_on" do
expect(page.depends_on).to eq([{ "not_joint_purchase?" => true }]) expect(page.depends_on).to eq([{ "not_joint_purchase?" => true }, { "jointpur" => nil }])
end end
context "with joint purchase" do context "with joint purchase" do

4
spec/models/form/sales/pages/old_persons_shared_ownership_value_check_spec.rb

@ -29,6 +29,10 @@ RSpec.describe Form::Sales::Pages::OldPersonsSharedOwnershipValueCheck, type: :m
"buyers_age_for_old_persons_shared_ownership_invalid?" => true, "buyers_age_for_old_persons_shared_ownership_invalid?" => true,
"not_joint_purchase?" => true, "not_joint_purchase?" => true,
}, },
{
"buyers_age_for_old_persons_shared_ownership_invalid?" => true,
"jointpur" => nil,
},
]) ])
end end

2
spec/models/form/sales/pages/privacy_notice_spec.rb

@ -34,7 +34,7 @@ RSpec.describe Form::Sales::Pages::PrivacyNotice, type: :model do
end end
it "has correct depends_on" do it "has correct depends_on" do
expect(page.depends_on).to eq([{ "not_joint_purchase?" => true }]) expect(page.depends_on).to eq([{ "not_joint_purchase?" => true }, { "jointpur" => nil }])
end end
context "with joint purchase" do context "with joint purchase" do

2
spec/models/form/sales/pages/savings_spec.rb

@ -28,7 +28,7 @@ RSpec.describe Form::Sales::Pages::Savings, type: :model do
end end
it "has correct depends_on" do it "has correct depends_on" do
expect(page.depends_on).to eq([{ "not_joint_purchase?" => true }]) expect(page.depends_on).to eq([{ "not_joint_purchase?" => true }, { "jointpur" => nil }])
end end
context "with joint purchase" do context "with joint purchase" do

2
spec/models/form/sales/pages/savings_value_check_spec.rb

@ -27,6 +27,8 @@ RSpec.describe Form::Sales::Pages::SavingsValueCheck, type: :model do
expect(page.depends_on).to eq([ expect(page.depends_on).to eq([
{ "not_joint_purchase?" => true, { "not_joint_purchase?" => true,
"savings_over_soft_max?" => true }, "savings_over_soft_max?" => true },
{ "jointpur" => nil,
"savings_over_soft_max?" => true },
]) ])
end end

9
spec/models/validations/shared_validations_spec.rb

@ -89,8 +89,9 @@ RSpec.describe Validations::SharedValidations do
it "adds the correct validation text when a question has a min but not a max" do it "adds the correct validation text when a question has a min but not a max" do
sales_log.savings = -10 sales_log.savings = -10
sales_log.jointpur = 1
shared_validator.validate_numeric_min_max(sales_log) shared_validator.validate_numeric_min_max(sales_log)
expect(sales_log.errors["savings"]).to include(match I18n.t("validations.numeric.above_min", field: "Buyers total savings before any deposit paid", min: "£0")) expect(sales_log.errors["savings"]).to include(match I18n.t("validations.numeric.above_min", field: "Buyers total savings before any deposit paid", min: "£0"))
end end
context "when validating percent" do context "when validating percent" do
@ -138,14 +139,16 @@ RSpec.describe Validations::SharedValidations do
context "when validating a question with a step of 10" do context "when validating a question with a step of 10" do
it "adds an error if input is not a multiple of ten" do it "adds an error if input is not a multiple of ten" do
sales_log.savings = 30_005 sales_log.savings = 30_005
sales_log.jointpur = 1
shared_validator.validate_numeric_step(sales_log) shared_validator.validate_numeric_step(sales_log)
expect(sales_log.errors[:savings]).to include I18n.t("validations.numeric.nearest_ten", field: "Buyers total savings before any deposit paid") expect(sales_log.errors[:savings]).to include I18n.t("validations.numeric.nearest_ten", field: "Buyers total savings before any deposit paid")
end end
it "adds an error if the user attempts to input a number in exponent format" do it "adds an error if the user attempts to input a number in exponent format" do
sales_log.savings = "3e5" sales_log.savings = "3e5"
sales_log.jointpur = 1
shared_validator.validate_numeric_step(sales_log) shared_validator.validate_numeric_step(sales_log)
expect(sales_log.errors[:savings]).to include I18n.t("validations.numeric.nearest_ten", field: "Buyers total savings before any deposit paid") expect(sales_log.errors[:savings]).to include I18n.t("validations.numeric.nearest_ten", field: "Buyers total savings before any deposit paid")
end end
it "does not add an error if input is a multiple of ten" do it "does not add an error if input is a multiple of ten" do

Loading…
Cancel
Save