Browse Source

make previous_la_known dynamically optional (#527)

pull/530/head
kosiakkatrina 3 years ago committed by GitHub
parent
commit
e70627bcf4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 5
      app/models/case_log.rb
  2. 1
      spec/factories/case_log.rb
  3. 2
      spec/fixtures/exports/case_logs.xml

5
app/models/case_log.rb

@ -50,7 +50,7 @@ class CaseLog < ApplicationRecord
}
AUTOGENERATED_FIELDS = %w[id status created_at updated_at discarded_at].freeze
OPTIONAL_FIELDS = %w[postcode_known previous_la_known first_time_property_let_as_social_housing tenant_code propcode].freeze
OPTIONAL_FIELDS = %w[first_time_property_let_as_social_housing tenant_code propcode].freeze
RENT_TYPE_MAPPING = { 0 => 1, 1 => 2, 2 => 2, 3 => 3, 4 => 3, 5 => 3 }.freeze
RENT_TYPE_MAPPING_LABELS = { 1 => "Social Rent", 2 => "Affordable Rent", 3 => "Intermediate Rent" }.freeze
HAS_BENEFITS_OPTIONS = [1, 6, 8, 7].freeze
@ -419,7 +419,8 @@ private
end
def dynamically_not_required
(form.invalidated_questions(self) + form.readonly_questions).map(&:id).uniq
previous_la_known_field = postcode_known? ? %w[previous_la_known] : []
((form.invalidated_questions(self) + form.readonly_questions).map(&:id) + previous_la_known_field).uniq
end
def set_derived_fields!

1
spec/factories/case_log.rb

@ -103,6 +103,7 @@ FactoryBot.define do
tenancyother { nil }
net_income_value_check { nil }
net_income_known { 1 }
previous_la_known { 1 }
property_owner_organisation { "Test" }
property_manager_organisation { "Test" }
renewal { 0 }

2
spec/fixtures/exports/case_logs.xml vendored

@ -132,7 +132,7 @@
<chcharge/>
<declaration>1</declaration>
<previous_postcode_known>1</previous_postcode_known>
<previous_la_known/>
<previous_la_known>1</previous_la_known>
<is_previous_la_inferred>false</is_previous_la_inferred>
<ethnic_other/>
<letting_allocation_unknown/>

Loading…
Cancel
Save