out_of_range:"Enter a value for the %{charge_name} between £0 and %{maximum_per_period} paid %{frequency}. %{maximum_per_period} is the max limit for rent and charges paid %{frequency} for %{letting_type} lettings owned by a %{provider_type}."
out_of_range:"Enter a value for the %{charge_name} between £0 and %{maximum_per_period} paid %{frequency}. %{maximum_per_period} is the max limit for rent and charges paid %{frequency} for %{letting_type} lettings owned by a %{provider_type}."
ecstat:
ecstat:
over_hard_max:"The household's income of %{earnings} %{frequency} is too high given the household’s working situation"
over_hard_max:"The household's income of %{earnings} %{frequency} is too high given the household’s working situation"
inferred_child:
under_hard_min:"The household's income of %{earnings} %{frequency} is too low given the household’s working situation"
over_hard_max:"The household's income of %{earnings} %{frequency} is too high given the household’s characteristics and working situation"
age:
earnings_over_hard_max:"The household's income of %{earnings} %{frequency} is too high for the number of adults. Change either the household income or the age of the tenants."
hhmemb:
earnings:
over_hard_max:"The household's income of %{earnings} %{frequency} is too high for this number of tenants. Change either the household income or number of tenants."
under_hard_min:"The household's income of %{earnings} %{frequency} is too low for this number of tenants. Change either the household income or number of tenants."
brent:
brent:
below_hard_min:"Rent is below the absolute minimum expected for a property of this type. Please check the rent, rent period, local authority and (if general needs) number of bedrooms"
below_hard_min:"Rent is below the absolute minimum expected for a property of this type. Please check the rent, rent period, local authority and (if general needs) number of bedrooms"
above_hard_max:"Rent is higher than the absolute maximum expected for a property of this type. Please check the rent, rent period, local authority and (if general needs) number of bedrooms"
above_hard_max:"Rent is higher than the absolute maximum expected for a property of this type. Please check the rent, rent period, local authority and (if general needs) number of bedrooms"
@ -190,6 +190,7 @@ RSpec.describe Validations::FinancialValidations do
it"validates that the net income is within the expected range for the household’s employment status"do
it"validates that the net income is within the expected range for the household’s employment status"do
record.earnings=200
record.earnings=200
record.incfreq=1
record.incfreq=1
record.hhmemb=1
record.ecstat1=1
record.ecstat1=1
financial_validator.validate_net_income(record)
financial_validator.validate_net_income(record)
expect(record.errors["earnings"]).tobe_empty
expect(record.errors["earnings"]).tobe_empty
@ -199,12 +200,15 @@ RSpec.describe Validations::FinancialValidations do
it"adds an error"do
it"adds an error"do
record.earnings=5000
record.earnings=5000
record.incfreq=1
record.incfreq=1
record.hhmemb=1
record.ecstat1=1
record.ecstat1=1
financial_validator.validate_net_income(record)
financial_validator.validate_net_income(record)
expect(record.errors["earnings"])
expect(record.errors["earnings"])
.toeq(["The household's income cannot be greater than £1,230.00 per week given the household’s working situation"])
.toeq(["The household's income cannot be greater than £1,230.00 per week given the household’s working situation"])
expect(record.errors["ecstat1"])
expect(record.errors["ecstat1"])
.toeq(["The household's income of £5,000.00 weekly is too high given the household’s working situation"])
.toeq(["The household's income of £5,000.00 weekly is too high given the household’s working situation"])
expect(record.errors["hhmemb"])
.toeq(["The household's income of £5,000.00 weekly is too high for this number of tenants. Change either the household income or number of tenants."])
end
end
end
end
@ -212,10 +216,15 @@ RSpec.describe Validations::FinancialValidations do
it"adds an error"do
it"adds an error"do
record.earnings=50
record.earnings=50
record.incfreq=1
record.incfreq=1
record.hhmemb=1
record.ecstat1=1
record.ecstat1=1
financial_validator.validate_net_income(record)
financial_validator.validate_net_income(record)
expect(record.errors["earnings"])
expect(record.errors["earnings"])
.toeq(["The household's income cannot be less than £90.00 per week given the household’s working situation"])
.toeq(["The household's income cannot be less than £90.00 per week given the household’s working situation"])
expect(record.errors["ecstat1"])
.toeq(["The household's income of £50.00 weekly is too low given the household’s working situation"])
expect(record.errors["hhmemb"])
.toeq(["The household's income of £50.00 weekly is too low for this number of tenants. Change either the household income or number of tenants."])
end
end
end
end
@ -260,7 +269,22 @@ RSpec.describe Validations::FinancialValidations do
expect(record.errors["age1"]).tobe_empty
expect(record.errors["age1"]).tobe_empty
expect(record.errors["age2"]).tobe_empty
expect(record.errors["age2"]).tobe_empty
expect(record.errors["age3"])
expect(record.errors["age3"])
.toeq(["The household's income of £5,000.00 weekly is too high given the household’s characteristics and working situation"])
.toeq(["The household's income of £5,000.00 weekly is too high for the number of adults. Change either the household income or the age of the tenants."])
end
it"adds errors to relevant fields for each tenant when income is too low"do
record.earnings=50
record.incfreq=1
record.hhmemb=3
record.ecstat1=1
record.ecstat2=2
record.age3=12
record.ecstat3=9
financial_validator.validate_net_income(record)
(1..record.hhmemb).eachdo|n|
expect(record.errors["ecstat#{n}"])
.toeq(["The household's income of £50.00 weekly is too low given the household’s working situation"])