Browse Source

CLDC-3487: Clear previous_la_known when necessary for renewal logs

pull/2452/head
Rachael Booth 2 years ago
parent
commit
8baa7f3822
  1. 2
      app/models/derived_variables/lettings_log_variables.rb
  2. 10
      spec/models/lettings_log_derived_fields_spec.rb

2
app/models/derived_variables/lettings_log_variables.rb

@ -123,7 +123,7 @@ module DerivedVariables::LettingsLogVariables
0 0
end end
self.is_previous_la_inferred = is_la_inferred self.is_previous_la_inferred = is_la_inferred
self.previous_la_known = 1 if la.present? self.previous_la_known = la.present? ? 1 : 0
self.prevloc = la self.prevloc = la
end end

10
spec/models/lettings_log_derived_fields_spec.rb

@ -987,6 +987,16 @@ RSpec.describe LettingsLog, type: :model do
.and change(log, :prevloc).to(expected_la) .and change(log, :prevloc).to(expected_la)
end end
it "clears values for previous location and related fields when log is a renewal and current values are cleared" do
log.assign_attributes(postcode_known: 0, postcode_full: nil, la: nil, renewal: 1, previous_la_known: 1, prevloc: "E09000033", ppostcode_full: "SW1A 1AA", ppcodenk: 0)
expect { log.set_derived_fields! }
.to change(log, :previous_la_known).to(0)
.and change(log, :prevloc).to(nil)
.and change(log, :ppcodenk).to(1)
.and change(log, :ppostcode_full).to(nil)
end
context "when the log is general needs" do context "when the log is general needs" do
context "and the managing organisation is a private registered provider" do context "and the managing organisation is a private registered provider" do
before do before do

Loading…
Cancel
Save