From ba4fc28c0f26c9141fbd95550a2fd8324e067db5 Mon Sep 17 00:00:00 2001 From: kiddhustle Date: Fri, 1 Apr 2022 15:18:24 +0100 Subject: [PATCH] CLCD-1074: amend specs --- app/models/case_log.rb | 5 ++--- app/models/validations/financial_validations.rb | 1 - spec/fixtures/exports/case_logs.xml | 2 +- spec/models/case_log_spec.rb | 16 ++++++++-------- .../validations/household_validations_spec.rb | 2 +- 5 files changed, 12 insertions(+), 14 deletions(-) diff --git a/app/models/case_log.rb b/app/models/case_log.rb index 98502cf64..6c9f6ae49 100644 --- a/app/models/case_log.rb +++ b/app/models/case_log.rb @@ -413,9 +413,8 @@ private self.prevten = 30 if managing_organisation.provider_type == "LA" end end - - self.landlord = 1 if owning_organisation.provider_type == "PRP" - self.landlord = 2 if owning_organisation.provider_type == "LA" + self.landlord = 1 if owning_organisation.provider_type == "LA" + self.landlord = 2 if owning_organisation.provider_type == "PRP" end def process_postcode_changes! diff --git a/app/models/validations/financial_validations.rb b/app/models/validations/financial_validations.rb index 36368343c..bd7007981 100644 --- a/app/models/validations/financial_validations.rb +++ b/app/models/validations/financial_validations.rb @@ -121,7 +121,6 @@ private def validate_charges(record) %i[scharge pscharge supcharg].each do |charge| maximum = CHARGE_MAXIMUMS.dig(charge, LANDLORD_VALUES[record.landlord], NEEDSTYPE_VALUES[record.needstype]) - if maximum.present? && record[charge].present? && !weekly_value_in_range(record, charge, 0, maximum) record.errors.add charge, I18n.t("validations.financial.rent.#{charge}.#{LANDLORD_VALUES[record.landlord]}.#{NEEDSTYPE_VALUES[record.needstype]}") end diff --git a/spec/fixtures/exports/case_logs.xml b/spec/fixtures/exports/case_logs.xml index 3d92cb834..1e05d6dc7 100644 --- a/spec/fixtures/exports/case_logs.xml +++ b/spec/fixtures/exports/case_logs.xml @@ -44,7 +44,7 @@ 0 5 3 - 2 + 1 SE26RT 7 2 diff --git a/spec/models/case_log_spec.rb b/spec/models/case_log_spec.rb index 1267f61e9..6db87249d 100644 --- a/spec/models/case_log_spec.rb +++ b/spec/models/case_log_spec.rb @@ -205,7 +205,7 @@ RSpec.describe CaseLog do net_income_known: 2, hhmemb: 7, rent_type: 4, - needstype: 1, + # needstype: 1, hb: 1, hbrentshortfall: 1, }) @@ -603,12 +603,12 @@ RSpec.describe CaseLog do expect(record_from_db["wtcharge"]).to eq(125.0) end - # it "correctly derives and saves landlord based on owning_organisation provider_type" do - # case_log.update!(owning_organisation: la_organisation) - # record_from_db = ActiveRecord::Base.connection.execute("select owning_organisation_id from case_logs where id=#{case_log.id}").to_a[0] - # expect(case_log.landlord).to eq(2) - # expect(record_from_db["landlord"]).to eq(2) - # end + it "correctly derives and saves landlord based on owning_organisation provider_type" do + case_log.update!(owning_organisation: la_organisation) + record_from_db = ActiveRecord::Base.connection.execute("select owning_organisation_id from case_logs where id=#{case_log.id}").to_a[0] + expect(case_log.landlord).to eq(1) + expect(record_from_db["landlord"]).to eq(1) + end context "when the tenant has an outstanding amount after benefits" do context "when tenant is in receipt of housing benefit" do @@ -1132,7 +1132,7 @@ RSpec.describe CaseLog do context "when any charge field is set" do before do - case_log.update!(pscharge: 10) + case_log.update!(pscharge: 10, period: 1) end it "derives that any blank ones are 0" do diff --git a/spec/models/validations/household_validations_spec.rb b/spec/models/validations/household_validations_spec.rb index 9d1a00282..8b30f2bfa 100644 --- a/spec/models/validations/household_validations_spec.rb +++ b/spec/models/validations/household_validations_spec.rb @@ -198,7 +198,7 @@ RSpec.describe Validations::HouseholdValidations do end it "cannot have `this landlord` as landlord and Housing situation before this letting cannot be LA general needs" do - record.landlord = 1 + record.owning_organisation.provider_type = 1 record.prevten = 30 record.referral = 1 household_validator.validate_referral(record)