Browse Source

remove unneeded table delete, fix indentation in error massages, fix validation to check for brent presence (#414)

pull/415/head
kosiakkatrina 3 years ago committed by GitHub
parent
commit
3a6df66d30
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      app/models/validations/financial_validations.rb
  2. 20
      config/locales/en.yml
  3. 4
      spec/lib/tasks/rent_range_import_spec.rb

2
app/models/validations/financial_validations.rb

@ -138,7 +138,7 @@ private
collection_year = record.collection_start_year
rent_range = LaRentRange.find_by(start_year: collection_year, la: record.la, beds: record.beds, lettype: record.lettype)
if rent_range.present? && !weekly_value_in_range(record, "brent", rent_range.hard_min, rent_range.hard_max)
if rent_range.present? && !weekly_value_in_range(record, "brent", rent_range.hard_min, rent_range.hard_max) && record.brent.present?
record.errors.add :brent, I18n.t("validations.financial.brent.not_in_range")
record.errors.add :beds, I18n.t("validations.financial.brent.beds.not_in_range")
record.errors.add :la, I18n.t("validations.financial.brent.la.not_in_range")

20
config/locales/en.yml

@ -118,16 +118,16 @@ en:
other_landlord:
general_needs: "Support charge must be between £0 and £60 per week if the landlord is another RP and it is a general needs letting"
supported_housing: "Support charge must be between £0 and £120 per week if the landlord is another RP and it is a suported housing letting"
brent:
not_in_range: "Basic rent is outside of the expected range based on the lettings type, local authority and number of bedrooms"
la:
not_in_range: "Basic rent is outside of the expected range based on this local authority"
beds:
not_in_range: "Basic rent is outside of the expected range based on this number of bedrooms"
needstype:
not_in_range: "Basic rent is outside of the expected range based on this lettings type"
rent_type:
not_in_range: "Basic rent is outside of the expected range based on this lettings type"
brent:
not_in_range: "Basic rent is outside of the expected range based on the lettings type, local authority and number of bedrooms"
la:
not_in_range: "Basic rent is outside of the expected range based on this local authority"
beds:
not_in_range: "Basic rent is outside of the expected range based on this number of bedrooms"
needstype:
not_in_range: "Basic rent is outside of the expected range based on this lettings type"
rent_type:
not_in_range: "Basic rent is outside of the expected range based on this lettings type"
charges:
complete_1_of_3: 'Only one question out of "Total charge", "Charges for carehomes" and "Does the household pay rent or charges?" needs to be selected and completed'
tcharge:

4
spec/lib/tasks/rent_range_import_spec.rb

@ -16,10 +16,6 @@ RSpec.describe "data_import" do
let(:rent_ranges_file_path) { "./spec/fixtures/files/rent_ranges.csv" }
let(:wrong_file_path) { "/test/no_csv_here.csv" }
before do
LaRentRange.delete_all
end
it "creates new rent range records" do
expect { task.invoke(start_year, rent_ranges_file_path) }.to change(LaRentRange, :count).by(5)
expect(LaRentRange.where(ranges_rent_id: 1).exists?).to be true

Loading…
Cancel
Save