Browse Source

More fixes

pull/2509/head
Rachael Booth 2 years ago
parent
commit
ee22a41652
  1. 18
      spec/models/validations/sales/financial_validations_spec.rb
  2. 1
      spec/services/bulk_upload/lettings/year2023/row_parser_spec.rb
  3. 2
      spec/services/bulk_upload/sales/log_creator_spec.rb

18
spec/models/validations/sales/financial_validations_spec.rb

@ -311,12 +311,10 @@ RSpec.describe Validations::Sales::FinancialValidations do
context "when buyer 2 is not a child" do
before do
record.update!(ecstat2: rand(0..8))
record.reload
record.ecstat2 = rand(0..8)
end
it "does not add an error if buyer 2 has an income" do
record.ecstat2 = rand(0..8)
record.income2 = 40_000
financial_validator.validate_child_income(record)
expect(record.errors).to be_empty
@ -324,32 +322,34 @@ RSpec.describe Validations::Sales::FinancialValidations do
end
context "when buyer 2 is a child" do
context "and saledate is current" do
let(:record) { build(:sales_log, :saledate_today, ecstat2: 9) }
it "does not add an error if buyer 2 has no income" do
record.saledate = Time.zone.local(2023, 4, 3)
record.ecstat2 = 9
record.income2 = 0
financial_validator.validate_child_income(record)
expect(record.errors).to be_empty
end
it "adds errors if buyer 2 has an income" do
record.saledate = Time.zone.local(2023, 4, 3)
record.ecstat2 = 9
record.income2 = 40_000
financial_validator.validate_child_income(record)
expect(record.errors["ecstat2"]).to include(match I18n.t("validations.financial.income.child_has_income"))
expect(record.errors["income2"]).to include(match I18n.t("validations.financial.income.child_has_income"))
end
end
context "and saledate is before the 23/24 collection window" do
let(:record) { build(:sales_log, saledate: Time.zone.local(2022, 4, 3), ecstat2: 9) }
it "does not add an error if the saledate is before the 23/24 collection window" do
record.saledate = Time.zone.local(2022, 4, 3)
record.ecstat2 = 9
record.income2 = 40_000
financial_validator.validate_child_income(record)
expect(record.errors).to be_empty
end
end
end
end
describe "#validate_equity_in_range_for_year_and_type" do
let(:record) { FactoryBot.build(:sales_log, saledate:) }

1
spec/services/bulk_upload/lettings/year2023/row_parser_spec.rb

@ -30,7 +30,6 @@ RSpec.describe BulkUpload::Lettings::Year2023::RowParser do
end
before do
allow(FormHandler.instance).to receive(:lettings_in_crossover_period?).and_return(true)
create(:organisation_relationship, parent_organisation: owning_org, child_organisation: managing_org)
LaRentRange.create!(

2
spec/services/bulk_upload/sales/log_creator_spec.rb

@ -93,7 +93,7 @@ RSpec.describe BulkUpload::Sales::LogCreator do
deposit: 10_000,
mortgageused: 1,
mortgage: 100_000,
grant: 10_000
grant: 10_000,
)
end

Loading…
Cancel
Save