|
|
|
@ -86,34 +86,34 @@ RSpec.describe Validations::FinancialValidations do
|
|
|
|
|
expect(record.errors["tshortfall"]).to be_empty |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
it "validates that the shortfall is a positive £ amount" do |
|
|
|
|
record.hb = 6 |
|
|
|
|
record.hbrentshortfall = 1 |
|
|
|
|
record.tshortfall_known = 0 |
|
|
|
|
record.tshortfall = 0 |
|
|
|
|
record.period = 2 |
|
|
|
|
record.set_derived_fields! |
|
|
|
|
financial_validator.validate_rent_amount(record) |
|
|
|
|
expect(record.errors["tshortfall"]) |
|
|
|
|
.to include(match I18n.t("validations.financial.tshortfall.must_be_positive")) |
|
|
|
|
end |
|
|
|
|
it "validates that the shortfall is a positive £ amount" do |
|
|
|
|
record.hb = 6 |
|
|
|
|
record.hbrentshortfall = 1 |
|
|
|
|
record.tshortfall_known = 0 |
|
|
|
|
record.tshortfall = 0 |
|
|
|
|
record.period = 2 |
|
|
|
|
record.set_derived_fields! |
|
|
|
|
financial_validator.validate_rent_amount(record) |
|
|
|
|
expect(record.errors["tshortfall"]) |
|
|
|
|
.to include(match I18n.t("validations.financial.tshortfall.must_be_positive")) |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
it "validates that basic rent is no less than the shortfall" do |
|
|
|
|
record.hb = 6 |
|
|
|
|
record.hbrentshortfall = 1 |
|
|
|
|
record.tshortfall_known = 0 |
|
|
|
|
record.tshortfall = 299.50 |
|
|
|
|
record.brent = 198 |
|
|
|
|
record.period = 2 |
|
|
|
|
record.set_derived_fields! |
|
|
|
|
financial_validator.validate_rent_amount(record) |
|
|
|
|
expect(record.errors["brent"]) |
|
|
|
|
.to include(match I18n.t("validations.financial.rent.less_than_shortfall")) |
|
|
|
|
expect(record.errors["tshortfall"]) |
|
|
|
|
.to include(match I18n.t("validations.financial.tshortfall.more_than_rent")) |
|
|
|
|
end |
|
|
|
|
it "validates that basic rent is no less than the shortfall" do |
|
|
|
|
record.hb = 6 |
|
|
|
|
record.hbrentshortfall = 1 |
|
|
|
|
record.tshortfall_known = 0 |
|
|
|
|
record.tshortfall = 299.50 |
|
|
|
|
record.brent = 198 |
|
|
|
|
record.period = 2 |
|
|
|
|
record.set_derived_fields! |
|
|
|
|
financial_validator.validate_rent_amount(record) |
|
|
|
|
expect(record.errors["brent"]) |
|
|
|
|
.to include(match I18n.t("validations.financial.rent.less_than_shortfall")) |
|
|
|
|
expect(record.errors["tshortfall"]) |
|
|
|
|
.to include(match I18n.t("validations.financial.tshortfall.more_than_rent")) |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
describe "rent period validations" do |
|
|
|
|
let(:organisation) { FactoryBot.create(:organisation) } |
|
|
|
|