Browse Source

Cldc 810 outside of the uk addresses (#323)

* Move previous_la into conditional question for la_known, add a hing and reset la if la_known is not Yes"

* update location json

* Update previous la known separately
pull/325/head
kosiakkatrina 3 years ago committed by GitHub
parent
commit
b47c7a5d91
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 8
      app/models/case_log.rb
  2. 38
      config/forms/2021_2022.json
  3. 17
      spec/models/case_log_spec.rb

8
app/models/case_log.rb

@ -309,15 +309,15 @@ private
end
def reset_location_fields!
reset_location(is_la_inferred, "la", "is_la_inferred", "property_postcode", "postcode", "postcod2")
reset_location(is_la_inferred, "la", "is_la_inferred", "property_postcode", "postcode", "postcod2", la_known)
end
def reset_previous_location_fields!
reset_location(is_previous_la_inferred, "prevloc", "is_previous_la_inferred", "previous_postcode", "ppostc1", "ppostc2")
reset_location(is_previous_la_inferred, "prevloc", "is_previous_la_inferred", "previous_postcode", "ppostc1", "ppostc2", previous_la_known)
end
def reset_location(is_inferred, la_key, is_inferred_key, postcode_key, incode_key, outcode_key)
if is_inferred
def reset_location(is_inferred, la_key, is_inferred_key, postcode_key, incode_key, outcode_key, is_la_known)
if is_inferred || is_la_known != "Yes"
self[la_key] = nil
end
self[is_inferred_key] = false

38
config/forms/2021_2022.json

@ -236,19 +236,11 @@
"0": {
"value": "No"
}
}
}
},
"depends_on": [
{
"is_la_inferred": false
"conditional_for": {
"la": ["Yes"]
}
]
},
"select_local_authority": {
"header": "",
"description": "",
"questions": {
"la": {
"check_answer_label": "Local Authority",
"header": "Select a local authority",
@ -577,7 +569,6 @@
},
"depends_on": [
{
"la_known": "Yes",
"is_la_inferred": false
}
]
@ -2487,7 +2478,7 @@
}
}
},
"previous_la_known": {
"previous_la": {
"header": "",
"description": "",
"questions": {
@ -2496,22 +2487,19 @@
"header": "Do you know the local authority of the household’s last settled accommodation?",
"hint_text": "This is also known as the household’s ’last settled home’.",
"type": "radio",
"hidden_in_check_answers": true,
"answer_options": {
"1": { "value": "Yes" },
"0": { "value": "No" }
}
}
},
"depends_on": [{ "is_previous_la_inferred": false }]
"conditional_for": {
"prevloc": ["Yes"]
}
},
"previous_la": {
"header": "",
"description": "",
"questions": {
"prevloc": {
"check_answer_label": "Location of household’s last settled accommodation",
"header": "Which local authority area did the household live in immediately before this letting?",
"hint_text": "Includes temporary accommodation.",
"header": "Select a local authority",
"hint_text": "Select ‘Northern Ireland’, ‘Scotland’, ‘Wales’ or ‘Outside the UK’ if the household’s last settled home was outside England.",
"type": "select",
"answer_options": {
"": "Select an option",
@ -2898,12 +2886,14 @@
"S92000003": "Scotland",
"W92000004": "Wales",
"9300000XX": "Outside UK"
},
"inferred_check_answers_value": {
"condition": { "previous_la_known": "No" },
"value": "Not known"
}
}
},
"depends_on": [
{ "previous_la_known": "Yes", "is_previous_la_inferred": false }
]
"depends_on": [{ "is_previous_la_inferred": false }]
},
"reasonable_preference": {
"header": "",

17
spec/models/case_log_spec.rb

@ -339,7 +339,7 @@ RSpec.describe CaseLog do
it "changes the LA if property postcode changes from not known to known and provided" do
address_case_log.update!({ postcode_known: "No" })
address_case_log.update!({ la: "Westminster" })
address_case_log.update!({ la_known: "Yes", la: "Westminster" })
record_from_db = ActiveRecord::Base.connection.execute("select la, property_postcode from case_logs where id=#{address_case_log.id}").to_a[0]
expect(record_from_db["property_postcode"]).to eq(nil)
@ -395,9 +395,22 @@ RSpec.describe CaseLog do
expect(record_from_db["prevloc"]).to eq(nil)
end
it "correctly resets la if la is not known" do
address_case_log.update!({ previous_postcode_known: "No" })
address_case_log.update!({ previous_la_known: "Yes", prevloc: "Scotland" })
record_from_db = ActiveRecord::Base.connection.execute("select prevloc from case_logs where id=#{address_case_log.id}").to_a[0]
expect(record_from_db["prevloc"]).to eq("S92000003")
expect(address_case_log.prevloc).to eq("Scotland")
address_case_log.update!({ previous_la_known: "No" })
record_from_db = ActiveRecord::Base.connection.execute("select prevloc from case_logs where id=#{address_case_log.id}").to_a[0]
expect(address_case_log.prevloc).to eq(nil)
expect(record_from_db["prevloc"]).to eq(nil)
end
it "changes the prevloc if previous postcode changes from not known to known and provided" do
address_case_log.update!({ previous_postcode_known: "No" })
address_case_log.update!({ prevloc: "Westminster" })
address_case_log.update!({ previous_la_known: "Yes", prevloc: "Westminster" })
record_from_db = ActiveRecord::Base.connection.execute("select prevloc, previous_postcode from case_logs where id=#{address_case_log.id}").to_a[0]
expect(record_from_db["previous_postcode"]).to eq(nil)

Loading…
Cancel
Save