Browse Source

Cldc 1424 display postcode question (#813)

* Reset wchair when needstype changes from supported housing to not supported housing

Co-authored-by: James Rose <jamesrose@users.noreply.github.com>

* remove location_id if scheme needstype changes to general needs

* only hide postcode known question from check your answers if it's answered

Co-authored-by: James Rose <jamesrose@users.noreply.github.com>
pull/814/head
kosiakkatrina 2 years ago committed by GitHub
parent
commit
563bfe1d95
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      app/models/case_log.rb
  2. 27
      config/forms/2021_2022.json
  3. 9
      config/forms/2022_2023.json
  4. 30
      spec/models/case_log_spec.rb

4
app/models/case_log.rb

@ -536,7 +536,9 @@ private
dependent_questions = { waityear: [{ key: :renewal, value: 0 }], dependent_questions = { waityear: [{ key: :renewal, value: 0 }],
homeless: [{ key: :renewal, value: 0 }], homeless: [{ key: :renewal, value: 0 }],
referral: [{ key: :renewal, value: 0 }], referral: [{ key: :renewal, value: 0 }],
underoccupation_benefitcap: [{ key: :renewal, value: 0 }] } underoccupation_benefitcap: [{ key: :renewal, value: 0 }],
wchair: [{ key: :needstype, value: 1 }],
location_id: [{ key: :needstype, value: 1 }] }
dependent_questions.each do |dependent, conditions| dependent_questions.each do |dependent, conditions|
condition_key = conditions.first[:key] condition_key = conditions.first[:key]

27
config/forms/2021_2022.json

@ -34,7 +34,14 @@
"conditional_for": { "conditional_for": {
"postcode_full": [1] "postcode_full": [1]
}, },
"hidden_in_check_answers": true "hidden_in_check_answers": {
"depends_on": [{
"postcode_known": 0
},
{
"postcode_known": 1
}]
}
}, },
"postcode_full": { "postcode_full": {
"check_answer_label": "Postcode", "check_answer_label": "Postcode",
@ -1122,7 +1129,11 @@
} }
}, },
"females_in_soft_age_range_in_pregnant_household_lead_hhmemb_value_check": { "females_in_soft_age_range_in_pregnant_household_lead_hhmemb_value_check": {
"depends_on": [{ "female_in_pregnant_household_in_soft_validation_range?": true }], "depends_on": [
{
"female_in_pregnant_household_in_soft_validation_range?": true
}
],
"title_text": { "title_text": {
"translation": "soft_validations.pregnancy.title", "translation": "soft_validations.pregnancy.title",
"arguments": [ "arguments": [
@ -1248,7 +1259,11 @@
} }
}, },
"females_in_soft_age_range_in_pregnant_household_lead_age_value_check": { "females_in_soft_age_range_in_pregnant_household_lead_age_value_check": {
"depends_on": [{ "female_in_pregnant_household_in_soft_validation_range?": true }], "depends_on": [
{
"female_in_pregnant_household_in_soft_validation_range?": true
}
],
"title_text": { "title_text": {
"translation": "soft_validations.pregnancy.title", "translation": "soft_validations.pregnancy.title",
"arguments": [ "arguments": [
@ -1356,7 +1371,11 @@
} }
}, },
"females_in_soft_age_range_in_pregnant_household_lead_value_check": { "females_in_soft_age_range_in_pregnant_household_lead_value_check": {
"depends_on": [{ "female_in_pregnant_household_in_soft_validation_range?": true }], "depends_on": [
{
"female_in_pregnant_household_in_soft_validation_range?": true
}
],
"title_text": { "title_text": {
"translation": "soft_validations.pregnancy.title", "translation": "soft_validations.pregnancy.title",
"arguments": [ "arguments": [

9
config/forms/2022_2023.json

@ -34,7 +34,14 @@
"conditional_for": { "conditional_for": {
"postcode_full": [1] "postcode_full": [1]
}, },
"hidden_in_check_answers": true "hidden_in_check_answers": {
"depends_on": [{
"postcode_known": 0
},
{
"postcode_known": 1
}]
}
}, },
"postcode_full": { "postcode_full": {
"check_answer_label": "Postcode", "check_answer_label": "Postcode",

30
spec/models/case_log_spec.rb

@ -1842,6 +1842,36 @@ RSpec.describe CaseLog do
end end
end end
context "when it changes from a supported housing to not a supported housing" do
let(:location) { FactoryBot.create(:location, mobility_type: "A", postcode: "SW1P 4DG") }
let(:case_log) { FactoryBot.create(:case_log, location:) }
it "resets inferred wchair value" do
case_log.update!({ needstype: 2 })
record_from_db = ActiveRecord::Base.connection.execute("select wchair from case_logs where id=#{case_log.id}").to_a[0]
expect(record_from_db["wchair"]).to eq(2)
expect(case_log["wchair"]).to eq(2)
case_log.update!({ needstype: 1 })
record_from_db = ActiveRecord::Base.connection.execute("select needstype from case_logs where id=#{case_log.id}").to_a[0]
expect(record_from_db["wchair"]).to eq(nil)
expect(case_log["wchair"]).to eq(nil)
end
it "resets location" do
case_log.update!({ needstype: 2 })
record_from_db = ActiveRecord::Base.connection.execute("select location_id from case_logs where id=#{case_log.id}").to_a[0]
expect(record_from_db["location_id"]).to eq(location.id)
expect(case_log["location_id"]).to eq(location.id)
case_log.update!({ needstype: 1 })
record_from_db = ActiveRecord::Base.connection.execute("select location_id from case_logs where id=#{case_log.id}").to_a[0]
expect(record_from_db["location_id"]).to eq(nil)
expect(case_log["location_id"]).to eq(nil)
end
end
context "when it is not a renewal" do context "when it is not a renewal" do
let(:case_log) { FactoryBot.create(:case_log) } let(:case_log) { FactoryBot.create(:case_log) }

Loading…
Cancel
Save