Browse Source

dynamically not required attributes for case logs

pull/54/head
MadeTech Dushan 3 years ago
parent
commit
9a8945ea9a
  1. 10
      app/models/case_log.rb
  2. 2
      spec/fixtures/complete_case_log.json

10
app/models/case_log.rb

@ -97,6 +97,14 @@ private
end end
def mandatory_fields def mandatory_fields
attributes.except(*AUTOGENERATED_FIELDS) required = attributes.except(*AUTOGENERATED_FIELDS)
dynamically_not_required = []
if reason_for_leaving_last_settled_home != "Other"
dynamically_not_required << "other_reason_for_leaving_last_settled_home"
end
required.delete_if { |key, _value| dynamically_not_required.include?(key) }
end end
end end

2
spec/fixtures/complete_case_log.json vendored

@ -89,7 +89,7 @@
"chr_letting": false, "chr_letting": false,
"cap_letting": false, "cap_letting": false,
"outstanding_rent_or_charges": 25, "outstanding_rent_or_charges": 25,
"other_reason_for_leaving_last_settled_home": "Other reason", "other_reason_for_leaving_last_settled_home": null,
"accessibility_requirements_fully_wheelchair_accessible_housing": true, "accessibility_requirements_fully_wheelchair_accessible_housing": true,
"accessibility_requirements_wheelchair_access_to_essential_rooms": false, "accessibility_requirements_wheelchair_access_to_essential_rooms": false,
"accessibility_requirements_level_access_housing": false, "accessibility_requirements_level_access_housing": false,

Loading…
Cancel
Save