Browse Source

when buyer is a company, do not route to household characteristics (#1336)

pull/1393/head
Arthur Campbell 2 years ago committed by GitHub
parent
commit
0216aae40f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 6
      app/models/form/sales/subsections/household_characteristics.rb
  2. 4
      app/models/sales_log.rb
  3. 1
      spec/factories/sales_log.rb
  4. 18
      spec/models/form/sales/subsections/household_characteristics_spec.rb

6
app/models/form/sales/subsections/household_characteristics.rb

@ -3,7 +3,7 @@ class Form::Sales::Subsections::HouseholdCharacteristics < ::Form::Subsection
super super
@id = "household_characteristics" @id = "household_characteristics"
@label = "Household characteristics" @label = "Household characteristics"
@depends_on = [{ "setup_completed?" => true }] @depends_on = [{ "setup_completed?" => true, "company_buyer?" => false }]
end end
def pages def pages
@ -92,4 +92,8 @@ class Form::Sales::Subsections::HouseholdCharacteristics < ::Form::Subsection
Form::Sales::Pages::Buyer2EthnicBackgroundWhite.new(nil, nil, self)] Form::Sales::Pages::Buyer2EthnicBackgroundWhite.new(nil, nil, self)]
end end
end end
def displayed_in_tasklist?(log)
!log.company_buyer?
end
end end

4
app/models/sales_log.rb

@ -262,6 +262,10 @@ class SalesLog < Log
ownershipsch == 1 ownershipsch == 1
end end
def company_buyer?
companybuy == 1
end
def buyers_age_for_old_persons_shared_ownership_invalid? def buyers_age_for_old_persons_shared_ownership_invalid?
return unless old_persons_shared_ownership? return unless old_persons_shared_ownership?

1
spec/factories/sales_log.rb

@ -14,7 +14,6 @@ FactoryBot.define do
ownershipsch { 2 } ownershipsch { 2 }
type { 8 } type { 8 }
saledate { Time.utc(2023, 2, 2, 10, 36, 49) } saledate { Time.utc(2023, 2, 2, 10, 36, 49) }
companybuy { 1 }
jointpur { 1 } jointpur { 1 }
beds { 2 } beds { 2 }
jointmore { 1 } jointmore { 1 }

18
spec/models/form/sales/subsections/household_characteristics_spec.rb

@ -195,6 +195,22 @@ RSpec.describe Form::Sales::Subsections::HouseholdCharacteristics, type: :model
end end
it "has correct depends on" do it "has correct depends on" do
expect(household_characteristics.depends_on).to eq([{ "setup_completed?" => true }]) expect(household_characteristics.depends_on).to eq([{ "setup_completed?" => true, "company_buyer?" => false }])
end
context "when the sale is to a company buyer" do
let(:log) { FactoryBot.create(:sales_log, ownershipsch: 3, companybuy: 1) }
it "is not displayed in tasklist" do
expect(household_characteristics.displayed_in_tasklist?(log)).to eq(false)
end
end
context "when the sale is not to a company buyer" do
let(:log) { FactoryBot.create(:sales_log, ownershipsch: 3, companybuy: 2) }
it "is displayed in tasklist" do
expect(household_characteristics.displayed_in_tasklist?(log)).to eq(true)
end
end end
end end

Loading…
Cancel
Save