Browse Source

Don’t uses slashes or abbreviations in questions

pull/210/head
Paul Robert Lloyd 3 years ago
parent
commit
3c79cf4100
  1. 10
      app/models/constants/case_log.rb
  2. 6
      app/models/validations/household_validations.rb
  3. 12
      config/forms/2021_2022.json
  4. 10
      docs/api/DLUHC-CORE-Data.v1.json
  5. 4
      spec/features/form/conditional_questions_spec.rb
  6. 6
      spec/fixtures/complete_case_log.json
  7. 8
      spec/fixtures/forms/2021_2022.json
  8. 6
      spec/models/case_log_spec.rb

10
app/models/constants/case_log.rb

@ -35,9 +35,9 @@ module Constants::CaseLog
}.freeze }.freeze
ETHNIC = { ETHNIC = {
"White: English/Scottish/Welsh/Northern Irish/British" => 1, "White: English, Welsh, Scottish, Northern Irish or British" => 1,
"White: Irish" => 2, "White: Irish" => 2,
"White: Gypsy/Irish Traveller" => 18, "White: Gypsy or Irish Traveller" => 18,
"White: Other" => 3, "White: Other" => 3,
"Mixed: White and Black Caribbean" => 4, "Mixed: White and Black Caribbean" => 4,
"Mixed: White and Black African" => 5, "Mixed: White and Black African" => 5,
@ -77,7 +77,7 @@ module Constants::CaseLog
NATIONAL = { NATIONAL = {
"UK national resident in UK" => 1, "UK national resident in UK" => 1,
"A current or former reserve in the UK Armed Forces (exc. National Service)" => 100, "A current or former reserve in the UK Armed Forces (excluding National Service)" => 100,
"UK national returning from residence overseas" => 2, "UK national returning from residence overseas" => 2,
"Czech Republic" => 3, "Czech Republic" => 3,
"Estonia" => 4, "Estonia" => 4,
@ -981,10 +981,10 @@ module Constants::CaseLog
}.freeze }.freeze
ARMED_FORCES = { ARMED_FORCES = {
"A current or former regular in the UK Armed Forces (exc. National Service)" => 1, "A current or former regular in the UK Armed Forces (excluding National Service)" => 1,
"No" => 2, "No" => 2,
"Tenant prefers not to say" => 3, "Tenant prefers not to say" => 3,
"A current or former reserve in the UK Armed Forces (exc. National Service)" => 4, "A current or former reserve in the UK Armed Forces (excluding National Service)" => 4,
"A spouse / civil partner of a UK Armed Forces member who has separated or been bereaved within the last 2 years" => 5, "A spouse / civil partner of a UK Armed Forces member who has separated or been bereaved within the last 2 years" => 5,
}.freeze }.freeze

6
app/models/validations/household_validations.rb

@ -26,7 +26,7 @@ module Validations::HouseholdValidations
end end
def validate_armed_forces_injured(record) def validate_armed_forces_injured(record)
if (record.armedforces == "A current or former regular in the UK Armed Forces (exc. National Service)" || record.armedforces == "A current or former reserve in the UK Armed Forces (exc. National Service)") && record.reservist.blank? if (record.armedforces == "A current or former regular in the UK Armed Forces (excluding National Service)" || record.armedforces == "A current or former reserve in the UK Armed Forces (excluding National Service)") && record.reservist.blank?
record.errors.add :reservist, "You must answer the armed forces injury question if the tenant has served in the armed forces" record.errors.add :reservist, "You must answer the armed forces injury question if the tenant has served in the armed forces"
end end
@ -36,11 +36,11 @@ module Validations::HouseholdValidations
end end
def validate_armed_forces_active_response(record) def validate_armed_forces_active_response(record)
if record.armedforces == "A current or former regular in the UK Armed Forces (exc. National Service)" && record.leftreg.blank? if record.armedforces == "A current or former regular in the UK Armed Forces (excluding National Service)" && record.leftreg.blank?
record.errors.add :leftreg, "You must answer the armed forces active question if the tenant has served as a regular in the armed forces" record.errors.add :leftreg, "You must answer the armed forces active question if the tenant has served as a regular in the armed forces"
end end
if record.armedforces != "A current or former regular in the UK Armed Forces (exc. National Service)" && record.leftreg.present? if record.armedforces != "A current or former regular in the UK Armed Forces (excluding National Service)" && record.leftreg.present?
record.errors.add :leftreg, "You must not answer the armed forces active question if the tenant has not served as a regular in the armed forces" record.errors.add :leftreg, "You must not answer the armed forces active question if the tenant has not served as a regular in the armed forces"
end end
end end

12
config/forms/2021_2022.json

@ -276,9 +276,9 @@
"hint_text": "", "hint_text": "",
"type": "radio", "type": "radio",
"answer_options": { "answer_options": {
"0": "White: English/Scottish/Welsh/Northern Irish/British", "0": "White: English, Welsh, Scottish, Northern Irish or British",
"1": "White: Irish", "1": "White: Irish",
"2": "White: Gypsy/Irish Traveller", "2": "White: Gypsy or Irish Traveller",
"3": "White: Other", "3": "White: Other",
"4": "Mixed: White and Black Caribbean", "4": "Mixed: White and Black Caribbean",
"5": "Mixed: White and Black African", "5": "Mixed: White and Black African",
@ -919,18 +919,18 @@
"type": "radio", "type": "radio",
"check_answer_label": "Armed Forces", "check_answer_label": "Armed Forces",
"answer_options": { "answer_options": {
"0": "A current or former regular in the UK Armed Forces (exc. National Service)", "0": "A current or former regular in the UK Armed Forces (excluding National Service)",
"1": "A current or former reserve in the UK Armed Forces (exc. National Service)", "1": "A current or former reserve in the UK Armed Forces (excluding National Service)",
"2": "A spouse / civil partner of a UK Armed Forces member who has separated or been bereaved within the last 2 years", "2": "A spouse / civil partner of a UK Armed Forces member who has separated or been bereaved within the last 2 years",
"3": "No", "3": "No",
"4": "Tenant prefers not to say" "4": "Tenant prefers not to say"
}, },
"conditional_for": { "conditional_for": {
"leftreg": [ "leftreg": [
"A current or former regular in the UK Armed Forces (exc. National Service)" "A current or former regular in the UK Armed Forces (excluding National Service)"
], ],
"reservist": [ "reservist": [
"A current or former regular in the UK Armed Forces (exc. National Service)" "A current or former regular in the UK Armed Forces (excluding National Service)"
] ]
} }
}, },

10
docs/api/DLUHC-CORE-Data.v1.json

@ -258,10 +258,10 @@
"tenant_code": "T657", "tenant_code": "T657",
"age1": 35, "age1": 35,
"sex1": "Female", "sex1": "Female",
"ethnic": "White: English/Scottish/Welsh/Northern Irish/British", "ethnic": "White: English, Welsh, Scottish, Northern Irish or British",
"national": "UK national resident in UK", "national": "UK national resident in UK",
"prevten": "Private sector tenancy", "prevten": "Private sector tenancy",
"armedforces": "A current or former regular in the UK Armed Forces (exc. National Service)", "armedforces": "A current or former regular in the UK Armed Forces (excluding National Service)",
"ecstat1": "Full-time - 30 hours or more", "ecstat1": "Full-time - 30 hours or more",
"other_hhmemb": 7, "other_hhmemb": 7,
"relat2": "Partner", "relat2": "Partner",
@ -389,9 +389,9 @@
"type": "string", "type": "string",
"minLength": 1, "minLength": 1,
"enum": [ "enum": [
"White: English/Scottish/Welsh/Northern Irish/British", "White: English, Welsh, Scottish, Northern Irish or British",
"White: Irish", "White: Irish",
"White: Gypsy/Irish Traveller", "White: Gypsy or Irish Traveller",
"White: Other", "White: Other",
"Mixed: White and Black Caribbean", "Mixed: White and Black Caribbean",
"Mixed: White and Black African", "Mixed: White and Black African",
@ -415,7 +415,7 @@
"minLength": 1, "minLength": 1,
"enum": [ "enum": [
"UK national resident in UK", "UK national resident in UK",
"A current or former reserve in the UK Armed Forces (exc. National Service)", "A current or former reserve in the UK Armed Forces (excluding National Service)",
"UK national returning from residence overseas", "UK national returning from residence overseas",
"Czech Republic", "Czech Republic",
"Estonia", "Estonia",

4
spec/features/form/conditional_questions_spec.rb

@ -29,13 +29,13 @@ RSpec.describe "Form Conditional Questions" do
it "shows conditional questions if the required answer is selected and hides it again when a different answer option is selected", js: true do it "shows conditional questions if the required answer is selected and hides it again when a different answer option is selected", js: true do
visit("/logs/#{id}/armed-forces") visit("/logs/#{id}/armed-forces")
# Something about our styling makes the selenium webdriver think the actual radio buttons are not visible so we allow label click here # Something about our styling makes the selenium webdriver think the actual radio buttons are not visible so we allow label click here
choose("case-log-armedforces-a-current-or-former-regular-in-the-uk-armed-forces-exc-national-service-field", allow_label_click: true) choose("case-log-armedforces-a-current-or-former-regular-in-the-uk-armed-forces-excluding-national-service-field", allow_label_click: true)
expect(page).to have_selector("#reservist_div") expect(page).to have_selector("#reservist_div")
choose("case-log-reservist-no-field", allow_label_click: true) choose("case-log-reservist-no-field", allow_label_click: true)
expect(page).to have_checked_field("case-log-reservist-no-field", visible: false) expect(page).to have_checked_field("case-log-reservist-no-field", visible: false)
choose("case-log-armedforces-no-field", allow_label_click: true) choose("case-log-armedforces-no-field", allow_label_click: true)
expect(page).not_to have_selector("#reservist_div") expect(page).not_to have_selector("#reservist_div")
choose("case-log-armedforces-a-current-or-former-regular-in-the-uk-armed-forces-exc-national-service-field", allow_label_click: true) choose("case-log-armedforces-a-current-or-former-regular-in-the-uk-armed-forces-excluding-national-service-field", allow_label_click: true)
expect(page).to have_unchecked_field("case-log-reservist-no-field", visible: false) expect(page).to have_unchecked_field("case-log-reservist-no-field", visible: false)
end end
end end

6
spec/fixtures/complete_case_log.json vendored

@ -3,11 +3,11 @@
"tenant_code": "T657", "tenant_code": "T657",
"age1": 35, "age1": 35,
"sex1": "Female", "sex1": "Female",
"ethnic": "White: English/Scottish/Welsh/Northern Irish/British", "ethnic": "White: English, Welsh, Scottish, Northern Irish or British",
"national": "UK national resident in UK", "national": "UK national resident in UK",
"prevten": "Private sector tenancy", "prevten": "Private sector tenancy",
"armedforces": "A current or former regular in the UK Armed Forces (exc. National Service)", "armedforces": "A current or former regular in the UK Armed Forces (excluding National Service)",
"armed_forces": "A current or former regular in the UK Armed Forces (exc. National Service)", "armed_forces": "A current or former regular in the UK Armed Forces (excluding National Service)",
"armed_forces_partner": "", "armed_forces_partner": "",
"ecstat1": "Full-time - 30 hours or more", "ecstat1": "Full-time - 30 hours or more",
"other_hhmemb": 7, "other_hhmemb": 7,

8
spec/fixtures/forms/2021_2022.json vendored

@ -117,15 +117,15 @@
"type": "radio", "type": "radio",
"check_answer_label": "Armed Forces", "check_answer_label": "Armed Forces",
"answer_options": { "answer_options": {
"0":"A current or former regular in the UK Armed Forces (exc. National Service)", "0":"A current or former regular in the UK Armed Forces (excluding National Service)",
"1":"A current or former reserve in the UK Armed Forces (exc. National Service)", "1":"A current or former reserve in the UK Armed Forces (excluding National Service)",
"2": "A spouse / civil partner of a UK Armed Forces member who has separated or been bereaved within the last 2 years", "2": "A spouse / civil partner of a UK Armed Forces member who has separated or been bereaved within the last 2 years",
"3": "No", "3": "No",
"4": "Tenant prefers not to say" "4": "Tenant prefers not to say"
}, },
"conditional_for": { "conditional_for": {
"leftreg": ["A current or former regular in the UK Armed Forces (exc. National Service)"], "leftreg": ["A current or former regular in the UK Armed Forces (excluding National Service)"],
"reservist": ["A current or former regular in the UK Armed Forces (exc. National Service)"] "reservist": ["A current or former regular in the UK Armed Forces (excluding National Service)"]
} }
}, },
"leftreg": { "leftreg": {

6
spec/models/case_log_spec.rb

@ -185,7 +185,7 @@ RSpec.describe Form, type: :model do
context "armed forces injured validation" do context "armed forces injured validation" do
it "must be answered if tenant was a regular or reserve in armed forces" do it "must be answered if tenant was a regular or reserve in armed forces" do
expect { expect {
CaseLog.create!(armedforces: "A current or former regular in the UK Armed Forces (exc. National Service)", CaseLog.create!(armedforces: "A current or former regular in the UK Armed Forces (excluding National Service)",
reservist: nil, reservist: nil,
owning_organisation: owning_organisation, owning_organisation: owning_organisation,
managing_organisation: managing_organisation) managing_organisation: managing_organisation)
@ -507,7 +507,7 @@ RSpec.describe Form, type: :model do
context "armed forces active validation" do context "armed forces active validation" do
it "must be answered if ever served in the forces as a regular" do it "must be answered if ever served in the forces as a regular" do
expect { expect {
CaseLog.create!(armedforces: "A current or former regular in the UK Armed Forces (exc. National Service)", CaseLog.create!(armedforces: "A current or former regular in the UK Armed Forces (excluding National Service)",
leftreg: nil, leftreg: nil,
owning_organisation: owning_organisation, owning_organisation: owning_organisation,
managing_organisation: managing_organisation) managing_organisation: managing_organisation)
@ -526,7 +526,7 @@ RSpec.describe Form, type: :model do
# Crossover over tests here as injured must be answered as well for no error # Crossover over tests here as injured must be answered as well for no error
it "must be answered if ever served in the forces as a regular" do it "must be answered if ever served in the forces as a regular" do
expect do expect do
CaseLog.create!(armedforces: "A current or former regular in the UK Armed Forces (exc. National Service)", CaseLog.create!(armedforces: "A current or former regular in the UK Armed Forces (excluding National Service)",
leftreg: "Yes", leftreg: "Yes",
reservist: "Yes", reservist: "Yes",
owning_organisation: owning_organisation, owning_organisation: owning_organisation,

Loading…
Cancel
Save