Browse Source

CLCD-1074: amend specs

pull/444/head
kiddhustle 4 years ago
parent
commit
ba4fc28c0f
  1. 5
      app/models/case_log.rb
  2. 1
      app/models/validations/financial_validations.rb
  3. 2
      spec/fixtures/exports/case_logs.xml
  4. 16
      spec/models/case_log_spec.rb
  5. 2
      spec/models/validations/household_validations_spec.rb

5
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!

1
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

2
spec/fixtures/exports/case_logs.xml vendored

@ -44,7 +44,7 @@
<startertenancy>0</startertenancy>
<tenancylength>5</tenancylength>
<tenancy>3</tenancy>
<landlord>2</landlord>
<landlord>1</landlord>
<ppostcode_full>SE26RT</ppostcode_full>
<rsnvac>7</rsnvac>
<unittype_gn>2</unittype_gn>

16
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

2
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)

Loading…
Cancel
Save