Browse Source

remove nullifying resonpref (#347)

pull/350/head
kosiakkatrina 3 years ago committed by GitHub
parent
commit
b934bc1ef4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      app/models/case_log.rb
  2. 23
      spec/models/case_log_spec.rb

1
app/models/case_log.rb

@ -302,7 +302,6 @@ private
self.homeless = 2
self.referral = 0
self.layear = 1
self.reasonpref = nil if given_reasonable_preference?
end
if is_general_needs?
self.prevten = 2 if managing_organisation.provider_type == "PRP"

23
spec/models/case_log_spec.rb

@ -645,29 +645,6 @@ RSpec.describe CaseLog do
expect(case_log["referral"]).to eq(0)
end
end
context "when it is not a renewal" do
let!(:case_log) do
described_class.create({
managing_organisation: organisation,
owning_organisation: organisation,
renewal: 0,
year: 2021,
})
end
it "correctly derives and saves reasonpref when changed to renewal" do
case_log.update!({ reasonpref: 1 })
record_from_db = ActiveRecord::Base.connection.execute("select reasonpref from case_logs where id=#{case_log.id}").to_a[0]
expect(record_from_db["reasonpref"]).to eq(1)
expect(case_log["reasonpref"]).to eq(1)
case_log.update!({ renewal: 1 })
record_from_db = ActiveRecord::Base.connection.execute("select reasonpref from case_logs where id=#{case_log.id}").to_a[0]
expect(record_from_db["reasonpref"]).to eq(nil)
expect(case_log["reasonpref"]).to eq(nil)
end
end
end
describe "resetting invalidated fields" do

Loading…
Cancel
Save