Browse Source

CLDC-2274 Fix buyer 2 nationality routing bug (#1546)

* feat: fix buyer 2 nationality routing, use helper methods everywhere

* feat: update tests and lint

* feat: update test

* refactor: lint

* feat: fix tests
pull/1553/head^2
natdeanlewissoftwire 2 years ago committed by GitHub
parent
commit
da218e073b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      app/models/form/sales/pages/age1.rb
  2. 8
      app/models/form/sales/pages/age2.rb
  3. 4
      app/models/form/sales/pages/buyer1_ethnic_group.rb
  4. 4
      app/models/form/sales/pages/buyer1_live_in_property.rb
  5. 4
      app/models/form/sales/pages/buyer1_working_situation.rb
  6. 8
      app/models/form/sales/pages/buyer2_ethnic_group.rb
  7. 2
      app/models/form/sales/pages/buyer2_income.rb
  8. 2
      app/models/form/sales/pages/buyer2_live_in_property.rb
  9. 2
      app/models/form/sales/pages/buyer2_mortgage.rb
  10. 11
      app/models/form/sales/pages/buyer2_nationality.rb
  11. 8
      app/models/form/sales/pages/buyer2_relationship_to_buyer1.rb
  12. 8
      app/models/form/sales/pages/buyer2_working_situation.rb
  13. 4
      app/models/form/sales/pages/gender_identity1.rb
  14. 8
      app/models/form/sales/pages/gender_identity2.rb
  15. 9
      app/models/form/sales/pages/housing_benefits.rb
  16. 2
      app/models/form/sales/pages/mortgage_value_check.rb
  17. 2
      app/models/form/sales/pages/nationality1.rb
  18. 2
      app/models/form/sales/pages/number_joint_buyers.rb
  19. 2
      app/models/form/sales/pages/number_of_others_in_property.rb
  20. 6
      app/models/form/sales/pages/person_known.rb
  21. 4
      app/models/sales_log.rb
  22. 2
      spec/models/form/sales/pages/age1_spec.rb
  23. 8
      spec/models/form/sales/pages/age2_spec.rb
  24. 2
      spec/models/form/sales/pages/buyer1_ethnic_group_spec.rb
  25. 2
      spec/models/form/sales/pages/buyer1_live_in_property_spec.rb
  26. 8
      spec/models/form/sales/pages/buyer2_ethnic_group_spec.rb
  27. 2
      spec/models/form/sales/pages/buyer2_income_spec.rb
  28. 2
      spec/models/form/sales/pages/buyer2_live_in_property_spec.rb
  29. 2
      spec/models/form/sales/pages/buyer2_mortgage_spec.rb
  30. 11
      spec/models/form/sales/pages/buyer2_nationality_spec.rb
  31. 8
      spec/models/form/sales/pages/buyer2_relationship_to_buyer1_spec.rb
  32. 8
      spec/models/form/sales/pages/buyer2_working_situation_spec.rb
  33. 2
      spec/models/form/sales/pages/gender_identity1_spec.rb
  34. 8
      spec/models/form/sales/pages/gender_identity2_spec.rb
  35. 4
      spec/models/form/sales/pages/housing_benefits_spec.rb
  36. 2
      spec/models/form/sales/pages/mortgage_value_check_spec.rb
  37. 2
      spec/models/form/sales/pages/nationality1_spec.rb
  38. 2
      spec/models/form/sales/pages/number_joint_buyers_spec.rb
  39. 4
      spec/models/form/sales/pages/number_of_others_in_property_spec.rb
  40. 14
      spec/models/form/sales/pages/person_known_spec.rb

4
app/models/form/sales/pages/age1.rb

@ -4,10 +4,10 @@ class Form::Sales::Pages::Age1 < ::Form::Page
@id = "buyer_1_age"
@depends_on = [
{
"privacynotice" => 1,
"buyer_has_seen_privacy_notice?" => true,
},
{
"noint" => 1,
"buyer_not_interviewed?" => true,
},
]
end

8
app/models/form/sales/pages/age2.rb

@ -4,12 +4,12 @@ class Form::Sales::Pages::Age2 < ::Form::Page
@id = "buyer_2_age"
@depends_on = [
{
"jointpur" => 1,
"privacynotice" => 1,
"joint_purchase?" => true,
"buyer_has_seen_privacy_notice?" => true,
},
{
"jointpur" => 1,
"noint" => 1,
"joint_purchase?" => true,
"buyer_not_interviewed?" => true,
},
]
end

4
app/models/form/sales/pages/buyer1_ethnic_group.rb

@ -4,10 +4,10 @@ class Form::Sales::Pages::Buyer1EthnicGroup < ::Form::Page
@id = "buyer_1_ethnic_group"
@depends_on = [
{
"privacynotice" => 1,
"buyer_has_seen_privacy_notice?" => true,
},
{
"noint" => 1,
"buyer_not_interviewed?" => true,
},
]
end

4
app/models/form/sales/pages/buyer1_live_in_property.rb

@ -4,10 +4,10 @@ class Form::Sales::Pages::Buyer1LiveInProperty < ::Form::Page
@id = "buyer_1_live_in_property"
@depends_on = [
{
"privacynotice" => 1,
"buyer_has_seen_privacy_notice?" => true,
},
{
"noint" => 1,
"buyer_not_interviewed?" => true,
},
]
end

4
app/models/form/sales/pages/buyer1_working_situation.rb

@ -4,10 +4,10 @@ class Form::Sales::Pages::Buyer1WorkingSituation < ::Form::Page
@id = "buyer_1_working_situation"
@depends_on = [
{
"privacynotice" => 1,
"buyer_has_seen_privacy_notice?" => true,
},
{
"noint" => 1,
"buyer_not_interviewed?" => true,
},
]
end

8
app/models/form/sales/pages/buyer2_ethnic_group.rb

@ -4,12 +4,12 @@ class Form::Sales::Pages::Buyer2EthnicGroup < ::Form::Page
@id = "buyer_2_ethnic_group"
@depends_on = [
{
"jointpur" => 1,
"privacynotice" => 1,
"joint_purchase?" => true,
"buyer_has_seen_privacy_notice?" => true,
},
{
"jointpur" => 1,
"noint" => 1,
"joint_purchase?" => true,
"buyer_not_interviewed?" => true,
},
]
end

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

@ -3,7 +3,7 @@ class Form::Sales::Pages::Buyer2Income < ::Form::Page
super
@id = "buyer_2_income"
@depends_on = [{
"jointpur" => 1,
"joint_purchase?" => true,
}]
end

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

@ -5,7 +5,7 @@ class Form::Sales::Pages::Buyer2LiveInProperty < ::Form::Page
@depends_on = [
{
"joint_purchase?" => true,
"privacynotice" => 1,
"buyer_has_seen_privacy_notice?" => true,
},
{
"joint_purchase?" => true,

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

@ -2,7 +2,7 @@ class Form::Sales::Pages::Buyer2Mortgage < ::Form::Page
def initialize(id, hsh, subsection)
super
@id = "buyer_2_mortgage"
@depends_on = [{ "jointpur" => 1 }]
@depends_on = [{ "joint_purchase?" => true }]
end
def questions

11
app/models/form/sales/pages/buyer2_nationality.rb

@ -2,7 +2,16 @@ class Form::Sales::Pages::Buyer2Nationality < ::Form::Page
def initialize(id, hsh, subsection)
super
@id = "buyer_2_nationality"
@depends_on = [{ "joint_purchase?" => true }]
@depends_on = [
{
"joint_purchase?" => true,
"buyer_has_seen_privacy_notice?" => true,
},
{
"joint_purchase?" => true,
"buyer_not_interviewed?" => true,
},
]
end
def questions

8
app/models/form/sales/pages/buyer2_relationship_to_buyer1.rb

@ -4,12 +4,12 @@ class Form::Sales::Pages::Buyer2RelationshipToBuyer1 < ::Form::Page
@id = "buyer_2_relationship_to_buyer_1"
@depends_on = [
{
"jointpur" => 1,
"privacynotice" => 1,
"joint_purchase?" => true,
"buyer_has_seen_privacy_notice?" => true,
},
{
"jointpur" => 1,
"noint" => 1,
"joint_purchase?" => true,
"buyer_not_interviewed?" => true,
},
]
end

8
app/models/form/sales/pages/buyer2_working_situation.rb

@ -4,12 +4,12 @@ class Form::Sales::Pages::Buyer2WorkingSituation < ::Form::Page
@id = "buyer_2_working_situation"
@depends_on = [
{
"jointpur" => 1,
"privacynotice" => 1,
"joint_purchase?" => true,
"buyer_has_seen_privacy_notice?" => true,
},
{
"jointpur" => 1,
"noint" => 1,
"joint_purchase?" => true,
"buyer_not_interviewed?" => true,
},
]
end

4
app/models/form/sales/pages/gender_identity1.rb

@ -4,10 +4,10 @@ class Form::Sales::Pages::GenderIdentity1 < ::Form::Page
@id = "buyer_1_gender_identity"
@depends_on = [
{
"privacynotice" => 1,
"buyer_has_seen_privacy_notice?" => true,
},
{
"noint" => 1,
"buyer_not_interviewed?" => true,
},
]
end

8
app/models/form/sales/pages/gender_identity2.rb

@ -4,12 +4,12 @@ class Form::Sales::Pages::GenderIdentity2 < ::Form::Page
@id = "buyer_2_gender_identity"
@depends_on = [
{
"jointpur" => 1,
"privacynotice" => 1,
"joint_purchase?" => true,
"buyer_has_seen_privacy_notice?" => true,
},
{
"jointpur" => 1,
"noint" => 1,
"joint_purchase?" => true,
"buyer_not_interviewed?" => true,
},
]
end

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

@ -2,7 +2,6 @@ class Form::Sales::Pages::HousingBenefits < ::Form::Page
def initialize(id, hsh, subsection, joint_purchase:)
super(id, hsh, subsection)
@joint_purchase = joint_purchase
@depends_on = [{ "jointpur" => @joint_purchase ? 1 : 2 }]
end
def questions
@ -10,4 +9,12 @@ class Form::Sales::Pages::HousingBenefits < ::Form::Page
Form::Sales::Questions::HousingBenefits.new(nil, nil, self, joint_purchase: @joint_purchase),
]
end
def depends_on
if @joint_purchase
[{ "joint_purchase?" => true }]
else
[{ "not_joint_purchase?" => true }]
end
end
end

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

@ -17,7 +17,7 @@ class Form::Sales::Pages::MortgageValueCheck < ::Form::Page
[
{
"mortgage_over_soft_max?" => true,
"jointpur" => 1,
"joint_purchase?" => true,
},
]
else

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

@ -4,7 +4,7 @@ class Form::Sales::Pages::Nationality1 < ::Form::Page
@id = "buyer_1_nationality"
@depends_on = [
{
"privacynotice" => 1,
"buyer_has_seen_privacy_notice?" => true,
},
{
"buyer_not_interviewed?" => true,

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

@ -3,7 +3,7 @@ class Form::Sales::Pages::NumberJointBuyers < ::Form::Page
super
@id = "number_joint_buyers"
@depends_on = [{
"jointpur" => 1,
"joint_purchase?" => true,
}]
end

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

@ -3,7 +3,7 @@ class Form::Sales::Pages::NumberOfOthersInProperty < ::Form::Page
super(id, hsh, subsection)
@depends_on = [
{
"privacynotice" => 1,
"buyer_has_seen_privacy_notice?" => true,
"joint_purchase?" => joint_purchase,
},
{

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

@ -13,18 +13,18 @@ class Form::Sales::Pages::PersonKnown < Form::Sales::Pages::Person
def depends_on
if @person_index == 2
[{ "jointpur" => 2,
[{ "not_joint_purchase?" => true,
"hholdcount" => {
"operator" => ">=",
"operand" => 1,
} }]
else
[{ "jointpur" => 2,
[{ "not_joint_purchase?" => true,
"hholdcount" => {
"operator" => ">=",
"operand" => @person_index - 1,
} },
{ "jointpur" => 1,
{ "joint_purchase?" => true,
"hholdcount" => {
"operator" => ">=",
"operand" => @person_index - 2,

4
app/models/sales_log.rb

@ -272,6 +272,10 @@ class SalesLog < Log
jointpur == 2
end
def buyer_has_seen_privacy_notice?
privacynotice == 1
end
def buyer_not_interviewed?
noint == 1
end

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

@ -28,6 +28,6 @@ RSpec.describe Form::Sales::Pages::Age1, type: :model do
end
it "has correct depends_on" do
expect(page.depends_on).to eq([{ "privacynotice" => 1 }, { "noint" => 1 }])
expect(page.depends_on).to eq([{ "buyer_has_seen_privacy_notice?" => true }, { "buyer_not_interviewed?" => true }])
end
end

8
spec/models/form/sales/pages/age2_spec.rb

@ -30,12 +30,12 @@ RSpec.describe Form::Sales::Pages::Age2, type: :model do
it "has correct depends_on" do
expect(page.depends_on).to eq([
{
"jointpur" => 1,
"privacynotice" => 1,
"joint_purchase?" => true,
"buyer_has_seen_privacy_notice?" => true,
},
{
"jointpur" => 1,
"noint" => 1,
"joint_purchase?" => true,
"buyer_not_interviewed?" => true,
},
])
end

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

@ -28,6 +28,6 @@ RSpec.describe Form::Sales::Pages::Buyer1EthnicGroup, type: :model do
end
it "has correct depends_on" do
expect(page.depends_on).to eq([{ "privacynotice" => 1 }, { "noint" => 1 }])
expect(page.depends_on).to eq([{ "buyer_has_seen_privacy_notice?" => true }, { "buyer_not_interviewed?" => true }])
end
end

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

@ -28,6 +28,6 @@ RSpec.describe Form::Sales::Pages::Buyer1LiveInProperty, type: :model do
end
it "has correct depends_on" do
expect(page.depends_on).to eq([{ "privacynotice" => 1 }, { "noint" => 1 }])
expect(page.depends_on).to eq([{ "buyer_has_seen_privacy_notice?" => true }, { "buyer_not_interviewed?" => true }])
end
end

8
spec/models/form/sales/pages/buyer2_ethnic_group_spec.rb

@ -30,12 +30,12 @@ RSpec.describe Form::Sales::Pages::Buyer2EthnicGroup, type: :model do
it "has correct depends_on" do
expect(page.depends_on).to eq([
{
"jointpur" => 1,
"privacynotice" => 1,
"joint_purchase?" => true,
"buyer_has_seen_privacy_notice?" => true,
},
{
"jointpur" => 1,
"noint" => 1,
"joint_purchase?" => true,
"buyer_not_interviewed?" => true,
},
])
end

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

@ -28,6 +28,6 @@ RSpec.describe Form::Sales::Pages::Buyer2Income, type: :model do
end
it "has correct depends_on" do
expect(page.depends_on).to eq([{ "jointpur" => 1 }])
expect(page.depends_on).to eq([{ "joint_purchase?" => true }])
end
end

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

@ -31,7 +31,7 @@ RSpec.describe Form::Sales::Pages::Buyer2LiveInProperty, type: :model do
expect(page.depends_on).to eq([
{
"joint_purchase?" => true,
"privacynotice" => 1,
"buyer_has_seen_privacy_notice?" => true,
},
{
"joint_purchase?" => true,

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

@ -28,6 +28,6 @@ RSpec.describe Form::Sales::Pages::Buyer2Mortgage, type: :model do
end
it "has correct depends_on" do
expect(page.depends_on).to eq([{ "jointpur" => 1 }])
expect(page.depends_on).to eq([{ "joint_purchase?" => true }])
end
end

11
spec/models/form/sales/pages/buyer2_nationality_spec.rb

@ -26,6 +26,15 @@ RSpec.describe Form::Sales::Pages::Buyer2Nationality, type: :model do
end
it "has correct depends_on" do
expect(page.depends_on).to eq [{ "joint_purchase?" => true }]
expect(page.depends_on).to eq [
{
"joint_purchase?" => true,
"buyer_has_seen_privacy_notice?" => true,
},
{
"joint_purchase?" => true,
"buyer_not_interviewed?" => true,
},
]
end
end

8
spec/models/form/sales/pages/buyer2_relationship_to_buyer1_spec.rb

@ -30,12 +30,12 @@ RSpec.describe Form::Sales::Pages::Buyer2RelationshipToBuyer1, type: :model do
it "has correct depends_on" do
expect(page.depends_on).to eq([
{
"jointpur" => 1,
"privacynotice" => 1,
"joint_purchase?" => true,
"buyer_has_seen_privacy_notice?" => true,
},
{
"jointpur" => 1,
"noint" => 1,
"joint_purchase?" => true,
"buyer_not_interviewed?" => true,
},
])
end

8
spec/models/form/sales/pages/buyer2_working_situation_spec.rb

@ -30,12 +30,12 @@ RSpec.describe Form::Sales::Pages::Buyer2WorkingSituation, type: :model do
it "has correct depends_on" do
expect(page.depends_on).to eq([
{
"jointpur" => 1,
"privacynotice" => 1,
"joint_purchase?" => true,
"buyer_has_seen_privacy_notice?" => true,
},
{
"jointpur" => 1,
"noint" => 1,
"joint_purchase?" => true,
"buyer_not_interviewed?" => true,
},
])
end

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

@ -28,6 +28,6 @@ RSpec.describe Form::Sales::Pages::GenderIdentity1, type: :model do
end
it "has correct depends_on" do
expect(page.depends_on).to eq([{ "privacynotice" => 1 }, { "noint" => 1 }])
expect(page.depends_on).to eq([{ "buyer_has_seen_privacy_notice?" => true }, { "buyer_not_interviewed?" => true }])
end
end

8
spec/models/form/sales/pages/gender_identity2_spec.rb

@ -30,12 +30,12 @@ RSpec.describe Form::Sales::Pages::GenderIdentity2, type: :model do
it "has correct depends_on" do
expect(page.depends_on).to eq([
{
"jointpur" => 1,
"privacynotice" => 1,
"joint_purchase?" => true,
"buyer_has_seen_privacy_notice?" => true,
},
{
"jointpur" => 1,
"noint" => 1,
"joint_purchase?" => true,
"buyer_not_interviewed?" => true,
},
])
end

4
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
it "has correct depends_on" do
expect(page.depends_on).to eq([{ "jointpur" => 2 }])
expect(page.depends_on).to eq([{ "not_joint_purchase?" => true }])
end
end
@ -38,7 +38,7 @@ RSpec.describe Form::Sales::Pages::HousingBenefits, type: :model do
let(:joint_purchase) { true }
it "has correct depends_on" do
expect(page.depends_on).to eq([{ "jointpur" => 1 }])
expect(page.depends_on).to eq([{ "joint_purchase?" => true }])
end
end
end

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

@ -43,7 +43,7 @@ RSpec.describe Form::Sales::Pages::MortgageValueCheck, type: :model do
expect(page.depends_on).to eq([
{
"mortgage_over_soft_max?" => true,
"jointpur" => 1,
"joint_purchase?" => true,
},
])
end

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

@ -26,6 +26,6 @@ RSpec.describe Form::Sales::Pages::Nationality1, type: :model do
end
it "has correct depends_on" do
expect(page.depends_on).to eq [{ "privacynotice" => 1 }, { "buyer_not_interviewed?" => true }]
expect(page.depends_on).to eq [{ "buyer_has_seen_privacy_notice?" => true }, { "buyer_not_interviewed?" => true }]
end
end

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

@ -28,6 +28,6 @@ RSpec.describe Form::Sales::Pages::NumberJointBuyers, type: :model do
end
it "has correct depends_on" do
expect(page.depends_on).to eq([{ "jointpur" => 1 }])
expect(page.depends_on).to eq([{ "joint_purchase?" => true }])
end
end

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

@ -31,7 +31,7 @@ RSpec.describe Form::Sales::Pages::NumberOfOthersInProperty, type: :model do
it "has the correct depends_on" do
expect(page.depends_on).to eq([
{
"privacynotice" => 1,
"buyer_has_seen_privacy_notice?" => true,
"joint_purchase?" => joint_purchase,
},
{
@ -52,7 +52,7 @@ RSpec.describe Form::Sales::Pages::NumberOfOthersInProperty, type: :model do
it "has the correct depends_on" do
expect(page.depends_on).to eq([
{
"privacynotice" => 1,
"buyer_has_seen_privacy_notice?" => true,
"joint_purchase?" => joint_purchase,
},
{

14
spec/models/form/sales/pages/person_known_spec.rb

@ -39,7 +39,7 @@ RSpec.describe Form::Sales::Pages::PersonKnown, type: :model do
it "has correct depends_on" do
expect(page.depends_on).to eq([{
"jointpur" => 2,
"not_joint_purchase?" => true,
"hholdcount" => {
"operator" => ">=",
"operand" => 1,
@ -67,14 +67,14 @@ RSpec.describe Form::Sales::Pages::PersonKnown, type: :model do
it "has correct depends_on" do
expect(page.depends_on).to eq([
{
"jointpur" => 2,
"not_joint_purchase?" => true,
"hholdcount" => {
"operator" => ">=",
"operand" => 2,
},
},
{
"jointpur" => 1,
"joint_purchase?" => true,
"hholdcount" => {
"operator" => ">=",
"operand" => 1,
@ -104,14 +104,14 @@ RSpec.describe Form::Sales::Pages::PersonKnown, type: :model do
it "has correct depends_on" do
expect(page.depends_on).to eq([
{
"jointpur" => 2,
"not_joint_purchase?" => true,
"hholdcount" => {
"operator" => ">=",
"operand" => 3,
},
},
{
"jointpur" => 1,
"joint_purchase?" => true,
"hholdcount" => {
"operator" => ">=",
"operand" => 2,
@ -140,14 +140,14 @@ RSpec.describe Form::Sales::Pages::PersonKnown, type: :model do
it "has correct depends_on" do
expect(page.depends_on).to eq([
{
"jointpur" => 2,
"not_joint_purchase?" => true,
"hholdcount" => {
"operator" => ">=",
"operand" => 4,
},
},
{
"jointpur" => 1,
"joint_purchase?" => true,
"hholdcount" => {
"operator" => ">=",
"operand" => 3,

Loading…
Cancel
Save