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. 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")

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