From 4945f1ebe296e474f5c0ca34fca3a262361e7320 Mon Sep 17 00:00:00 2001 From: Kat Date: Wed, 23 Mar 2022 16:50:36 +0000 Subject: [PATCH] remove unneeded table delete, fix indentation in error massages, fix validation to check for brent presence --- .../validations/financial_validations.rb | 2 +- config/locales/en.yml | 20 +++++++++---------- spec/lib/tasks/rent_range_import_spec.rb | 4 ---- 3 files changed, 11 insertions(+), 15 deletions(-) diff --git a/app/models/validations/financial_validations.rb b/app/models/validations/financial_validations.rb index 7c663b1e6..d4ea7e11e 100644 --- a/app/models/validations/financial_validations.rb +++ b/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") diff --git a/config/locales/en.yml b/config/locales/en.yml index e4f71e8c9..0e43522a7 100644 --- a/config/locales/en.yml +++ b/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: diff --git a/spec/lib/tasks/rent_range_import_spec.rb b/spec/lib/tasks/rent_range_import_spec.rb index 755571fab..e78f32ac1 100644 --- a/spec/lib/tasks/rent_range_import_spec.rb +++ b/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