Browse Source

update location json

pull/323/head
Kat 3 years ago
parent
commit
e10ba519df
  1. 4
      app/models/case_log.rb
  2. 19
      config/forms/2021_2022.json
  3. 14
      spec/models/case_log_spec.rb

4
app/models/case_log.rb

@ -309,11 +309,11 @@ private
end
def reset_location_fields!
reset_location(is_la_inferred, "la", "is_la_inferred", "property_postcode", "postcode", "postcod2", self.la_known)
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", self.previous_la_known)
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, is_la_known)

19
config/forms/2021_2022.json

@ -236,19 +236,11 @@
"0": {
"value": "No"
}
},
"conditional_for": {
"la": ["Yes"]
}
}
},
"depends_on": [
{
"is_la_inferred": false
}
]
},
"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
}
]
@ -2506,7 +2497,7 @@
},
"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?",
"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": {

14
spec/models/case_log_spec.rb

@ -396,15 +396,15 @@ RSpec.describe CaseLog do
end
it "correctly resets la if la is not known" do
address_case_log.update!({ previous_la_known: "Yes", previous_la: "Scotland" })
record_from_db = ActiveRecord::Base.connection.execute("select previous_la from case_logs where id=#{address_case_log.id}").to_a[0]
expect(record_from_db["previous_la"]).to eq(nil)
expect(address_case_log.previous_la).to eq("Scotland")
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 previous_la from case_logs where id=#{address_case_log.id}").to_a[0]
expect(address_case_log.previous_la).to eq(nil)
expect(record_from_db["previous_la"]).to eq(nil)
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

Loading…
Cancel
Save