Browse Source

Remove depends_on companybuy which has been removed

pull/2774/head
Manny Dinssa 9 months ago
parent
commit
bf83b79ac1
  1. 11
      app/models/form/sales/subsections/household_characteristics.rb
  2. 60
      spec/models/form/sales/subsections/household_characteristics_spec.rb

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

@ -3,7 +3,14 @@ class Form::Sales::Subsections::HouseholdCharacteristics < ::Form::Subsection
super
@id = "household_characteristics"
@label = "Household characteristics"
@depends_on = [{ "setup_completed?" => true, "company_buyer?" => false }]
end
def depends_on
if form.start_year_2025_or_later?
[{ "setup_completed?" => true }]
else
[{ "setup_completed?" => true, "company_buyer?" => false }]
end
end
def pages
@ -143,6 +150,8 @@ class Form::Sales::Subsections::HouseholdCharacteristics < ::Form::Subsection
end
def displayed_in_tasklist?(log)
return true if form.start_year_2025_or_later?
!log.company_buyer?
end
end

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

@ -16,6 +16,14 @@ RSpec.describe Form::Sales::Subsections::HouseholdCharacteristics, type: :model
expect(household_characteristics.section).to eq(section)
end
it "has the correct id" do
expect(household_characteristics.id).to eq("household_characteristics")
end
it "has the correct label" do
expect(household_characteristics.label).to eq("Household characteristics")
end
context "with 2022/23 form" do
before do
allow(form).to receive(:start_date).and_return(Time.zone.local(2022, 4, 1))
@ -234,6 +242,26 @@ RSpec.describe Form::Sales::Subsections::HouseholdCharacteristics, type: :model
allow(form).to receive(:start_year_2025_or_later?).and_return(false)
end
it "has correct depends on" do
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.build(: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.build(:sales_log, ownershipsch: 3, companybuy: 2) }
it "is displayed in tasklist" do
expect(household_characteristics.displayed_in_tasklist?(log)).to eq(true)
end
end
it "has correct pages" do
expect(household_characteristics.pages.map(&:id)).to eq(
%w[
@ -368,6 +396,10 @@ RSpec.describe Form::Sales::Subsections::HouseholdCharacteristics, type: :model
allow(form).to receive(:start_year_2025_or_later?).and_return(true)
end
it "has correct depends on" do
expect(household_characteristics.depends_on).to eq([{ "setup_completed?" => true }])
end
it "has correct pages" do
expect(household_characteristics.pages.map(&:id)).to eq(
%w[
@ -494,32 +526,4 @@ RSpec.describe Form::Sales::Subsections::HouseholdCharacteristics, type: :model
)
end
end
it "has the correct id" do
expect(household_characteristics.id).to eq("household_characteristics")
end
it "has the correct label" do
expect(household_characteristics.label).to eq("Household characteristics")
end
it "has correct depends on" do
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.build(: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.build(: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

Loading…
Cancel
Save