|
|
@ -735,6 +735,7 @@ RSpec.describe Validations::FinancialValidations do |
|
|
|
record.la = "E07000223" |
|
|
|
record.la = "E07000223" |
|
|
|
record.beds = 1 |
|
|
|
record.beds = 1 |
|
|
|
record.year = 2021 |
|
|
|
record.year = 2021 |
|
|
|
|
|
|
|
record.startdate = Time.zone.local(2021, 9, 17) |
|
|
|
record.brent = 9.17 |
|
|
|
record.brent = 9.17 |
|
|
|
|
|
|
|
|
|
|
|
financial_validator.validate_rent_amount(record) |
|
|
|
financial_validator.validate_rent_amount(record) |
|
|
@ -747,17 +748,51 @@ RSpec.describe Validations::FinancialValidations do |
|
|
|
record.period = 1 |
|
|
|
record.period = 1 |
|
|
|
record.la = "E07000223" |
|
|
|
record.la = "E07000223" |
|
|
|
record.beds = 1 |
|
|
|
record.beds = 1 |
|
|
|
|
|
|
|
record.startdate = Time.zone.local(2021, 9, 17) |
|
|
|
record.year = 2021 |
|
|
|
record.year = 2021 |
|
|
|
record.brent = 200 |
|
|
|
record.brent = 200 |
|
|
|
|
|
|
|
|
|
|
|
financial_validator.validate_rent_amount(record) |
|
|
|
financial_validator.validate_rent_amount(record) |
|
|
|
expect(record.errors["brent"]) |
|
|
|
expect(record.errors["brent"]) |
|
|
|
.to include(match I18n.t("validations.financial.brent.not_in_range")) |
|
|
|
.to include(match I18n.t("validations.financial.brent.not_in_range")) |
|
|
|
|
|
|
|
expect(record.errors["beds"]) |
|
|
|
|
|
|
|
.to include(match I18n.t("validations.financial.brent.beds.not_in_range")) |
|
|
|
|
|
|
|
expect(record.errors["la"]) |
|
|
|
|
|
|
|
.to include(match I18n.t("validations.financial.brent.la.not_in_range")) |
|
|
|
|
|
|
|
expect(record.errors["rent_type"]) |
|
|
|
|
|
|
|
.to include(match I18n.t("validations.financial.brent.rent_type.not_in_range")) |
|
|
|
|
|
|
|
expect(record.errors["needstype"]) |
|
|
|
|
|
|
|
.to include(match I18n.t("validations.financial.brent.needstype.not_in_range")) |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
it "validates hard max for correct collection year" do |
|
|
|
|
|
|
|
record.lettype = 1 |
|
|
|
|
|
|
|
record.period = 1 |
|
|
|
|
|
|
|
record.la = "E07000223" |
|
|
|
|
|
|
|
record.startdate = Time.zone.local(2022, 2, 5) |
|
|
|
|
|
|
|
record.beds = 1 |
|
|
|
|
|
|
|
record.year = 2022 |
|
|
|
|
|
|
|
record.month = 2 |
|
|
|
|
|
|
|
record.day = 5 |
|
|
|
|
|
|
|
record.brent = 200 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
financial_validator.validate_rent_amount(record) |
|
|
|
|
|
|
|
expect(record.errors["brent"]) |
|
|
|
|
|
|
|
.to include(match I18n.t("validations.financial.brent.not_in_range")) |
|
|
|
|
|
|
|
expect(record.errors["beds"]) |
|
|
|
|
|
|
|
.to include(match I18n.t("validations.financial.brent.beds.not_in_range")) |
|
|
|
|
|
|
|
expect(record.errors["la"]) |
|
|
|
|
|
|
|
.to include(match I18n.t("validations.financial.brent.la.not_in_range")) |
|
|
|
|
|
|
|
expect(record.errors["rent_type"]) |
|
|
|
|
|
|
|
.to include(match I18n.t("validations.financial.brent.rent_type.not_in_range")) |
|
|
|
|
|
|
|
expect(record.errors["needstype"]) |
|
|
|
|
|
|
|
.to include(match I18n.t("validations.financial.brent.needstype.not_in_range")) |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
it "does not error if some of the fields are missing" do |
|
|
|
it "does not error if some of the fields are missing" do |
|
|
|
record.managing_organisation.provider_type = 2 |
|
|
|
record.managing_organisation.provider_type = 2 |
|
|
|
record.year = 2021 |
|
|
|
record.year = 2021 |
|
|
|
|
|
|
|
record.startdate = Time.zone.local(2021, 9, 17) |
|
|
|
record.brent = 200 |
|
|
|
record.brent = 200 |
|
|
|
|
|
|
|
|
|
|
|
financial_validator.validate_rent_amount(record) |
|
|
|
financial_validator.validate_rent_amount(record) |
|
|
|