Browse Source

Infer underoccupation_benefitcap if it is a renewal

pull/285/head
Kat 3 years ago
parent
commit
89045e63d1
  1. 1
      app/models/case_log.rb
  2. 7
      spec/models/case_log_spec.rb

1
app/models/case_log.rb

@ -253,6 +253,7 @@ private
self.has_benefits = get_has_benefits
self.nocharge = household_charge == "Yes" ? "No" : "Yes"
self.layear = "Less than 1 year" if renewal == "Yes"
self.underoccupation_benefitcap = "No" if renewal == "Yes" && year == 2021
end
def process_postcode_changes!

7
spec/models/case_log_spec.rb

@ -1160,6 +1160,7 @@ RSpec.describe CaseLog do
managing_organisation: organisation,
owning_organisation: organisation,
renewal: "Yes",
year: 2021,
})
end
@ -1168,6 +1169,12 @@ RSpec.describe CaseLog do
expect(record_from_db["layear"]).to eq(2)
expect(case_log["layear"]).to eq("Less than 1 year")
end
it "correctly derives and saves underoccupation_benefitcap if year is 2021" do
record_from_db = ActiveRecord::Base.connection.execute("select underoccupation_benefitcap from case_logs where id=#{case_log.id}").to_a[0]
expect(record_from_db["underoccupation_benefitcap"]).to eq(2)
expect(case_log["underoccupation_benefitcap"]).to eq("No")
end
end
end

Loading…
Cancel
Save