Browse Source

Refactoring

pull/2509/head
Rachael Booth 2 years ago
parent
commit
bbc8cc82b5
  1. 28
      spec/models/validations/sales/financial_validations_spec.rb
  2. 15
      spec/support/bulk_upload/lettings_log_to_csv.rb

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

@ -320,21 +320,19 @@ RSpec.describe Validations::Sales::FinancialValidations do
end end
context "when buyer 2 is a child" do context "when buyer 2 is a child" do
context "and saledate is current" do let(:record) { build(:sales_log, :saledate_today, ecstat2: 9) }
let(:record) { build(:sales_log, :saledate_today, ecstat2: 9) }
it "does not add an error if buyer 2 has no income" do
it "does not add an error if buyer 2 has no income" do record.income2 = 0
record.income2 = 0 financial_validator.validate_child_income(record)
financial_validator.validate_child_income(record) expect(record.errors).to be_empty
expect(record.errors).to be_empty end
end
it "adds errors if buyer 2 has an income" do
it "adds errors if buyer 2 has an income" do record.income2 = 40_000
record.income2 = 40_000 financial_validator.validate_child_income(record)
financial_validator.validate_child_income(record) expect(record.errors["ecstat2"]).to include(match I18n.t("validations.financial.income.child_has_income"))
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"))
expect(record.errors["income2"]).to include(match I18n.t("validations.financial.income.child_has_income"))
end
end end
end end
end end

15
spec/support/bulk_upload/lettings_log_to_csv.rb

@ -477,20 +477,7 @@ private
end end
def rent_type def rent_type
case log.rent_type LettingsLog::RENTTYPE_DETAIL_MAPPING[log.rent_type]
when LettingsLog::RENT_TYPE[:social_rent]
1
when LettingsLog::RENT_TYPE[:affordable_rent]
2
when LettingsLog::RENT_TYPE[:london_affordable_rent]
3
when LettingsLog::RENT_TYPE[:rent_to_buy]
4
when LettingsLog::RENT_TYPE[:london_living_rent]
5
when LettingsLog::RENT_TYPE[:other_intermediate_rent_product]
6
end
end end
def leftreg def leftreg

Loading…
Cancel
Save