Browse Source

Add redundant routing to LA question logic

CLDC-4461-hide-confidential-addresses
oscric 2 days ago
parent
commit
eaaf5ce12b
  1. 7
      app/models/derived_variables/lettings_log_variables.rb
  2. 1
      app/models/form/lettings/pages/property_local_authority.rb
  3. 2
      app/models/lettings_log.rb
  4. 4
      app/models/scheme.rb
  5. 2
      app/services/bulk_upload/lettings/year2026/row_parser.rb
  6. 7
      spec/models/form/lettings/pages/property_local_authority_spec.rb
  7. 15
      spec/models/lettings_log_derived_fields_spec.rb

7
app/models/derived_variables/lettings_log_variables.rb

@ -188,13 +188,6 @@ module DerivedVariables::LettingsLogVariables
self.uprn_selection = nil
self.postcode_known = nil
self.manual_address_entry_selected = nil
location_la = location_derived_la
if location_la.present?
self.la = location_la
self.is_la_inferred = true
else
self.is_la_inferred = false
end
end
set_checkbox_values!

1
app/models/form/lettings/pages/property_local_authority.rb

@ -5,7 +5,6 @@ class Form::Lettings::Pages::PropertyLocalAuthority < ::Form::Page
@depends_on = [
{ "is_la_inferred" => false, "is_general_needs?" => true, "form.start_year_2025_or_later?" => false, "address_search_given?" => true },
{ "is_la_inferred" => false, "is_general_needs?" => true, "form.start_year_2025_or_later?" => true },
{ "is_la_inferred" => false, "scheme_has_confidential_information?" => true },
]
end

2
app/models/lettings_log.rb

@ -828,7 +828,7 @@ class LettingsLog < Log
end
def scheme_has_confidential_information?
scheme&.sensitive == "Yes"
scheme&.has_confidential_information? || false
end
def referral_is_from_local_authority_housing_register?

4
app/models/scheme.rb

@ -367,6 +367,10 @@ class Scheme < ApplicationRecord
status_at(6.months.from_now) == :deactivating_soon
end
def has_confidential_information?
sensitive == "Yes"
end
def discard!
update!(discarded_at: Time.zone.now)
locations.each(&:discard!)

2
app/services/bulk_upload/lettings/year2026/row_parser.rb

@ -1589,7 +1589,7 @@ private
end
def scheme_has_confidential_information?
scheme&.sensitive == "Yes"
scheme&.has_confidential_information? || false
end
def startdate

7
spec/models/form/lettings/pages/property_local_authority_spec.rb

@ -60,13 +60,8 @@ RSpec.describe Form::Lettings::Pages::PropertyLocalAuthority, type: :model do
context "when the scheme is confidential" do
let(:log) { build(:lettings_log, needstype: 2, scheme: build(:scheme, sensitive: 1)) }
it "is routed to when the LA could not be inferred, even for supported housing" do
it "is not routed to, even when the LA could not be inferred" do
log.is_la_inferred = false
expect(page).to be_routed_to(log, nil)
end
it "is not routed to when the LA was inferred from the location" do
log.is_la_inferred = true
expect(page).not_to be_routed_to(log, nil)
end
end

15
spec/models/lettings_log_derived_fields_spec.rb

@ -1649,25 +1649,12 @@ RSpec.describe LettingsLog, type: :model do
location.update_column(:location_code, nil)
end
it "does not infer an LA, so the user is routed to the LA drop-down" do
log.la = nil
it "leaves the LA blank and not inferred" do
log.set_derived_fields!
expect(log.read_attribute(:la)).to be_nil
expect(log.is_la_inferred).to be false
end
it "keeps a manually chosen LA when one has been provided" do
# In the real edit flow the log is persisted, so the location/startdate have not
# "changed" and the earlier LA-reset branches do not fire. Stub those guards to
# isolate the confidential handling, which must not clobber the drop-down answer.
allow(log).to receive_messages(startdate_changed?: false, location_changed?: false)
log.la = "E07000105"
log.set_derived_fields!
expect(log.read_attribute(:la)).to eq("E07000105")
expect(log.is_la_inferred).to be false
end
end
context "when the log is also a new-build first let" do

Loading…
Cancel
Save