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
ETHNIC = {
"White: English/Scottish/Welsh/Northern Irish/British" => 1,
"White: English, Welsh, Scottish, Northern Irish or British" => 1,
"White: Irish" => 2,
"White: Gypsy/Irish Traveller" => 18,
"White: Gypsy or Irish Traveller" => 18,
"White: Other" => 3,
"Mixed: White and Black Caribbean" => 4,
"Mixed: White and Black African" => 5,
@ -77,7 +77,7 @@ module Constants::CaseLog
NATIONAL = {
"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,
"Czech Republic" => 3,
"Estonia" => 4,
@ -981,10 +981,10 @@ module Constants::CaseLog
}.freeze
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,
"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,
}.freeze

6
app/models/validations/household_validations.rb

@ -26,7 +26,7 @@ module Validations::HouseholdValidations
end
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"
end
@ -36,11 +36,11 @@ module Validations::HouseholdValidations
end
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"
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"
end
end

12
config/forms/2021_2022.json

@ -276,9 +276,9 @@
"hint_text": "",
"type": "radio",
"answer_options": {
"0": "White: English/Scottish/Welsh/Northern Irish/British",
"0": "White: English, Welsh, Scottish, Northern Irish or British",
"1": "White: Irish",
"2": "White: Gypsy/Irish Traveller",
"2": "White: Gypsy or Irish Traveller",
"3": "White: Other",
"4": "Mixed: White and Black Caribbean",
"5": "Mixed: White and Black African",
@ -919,18 +919,18 @@
"type": "radio",
"check_answer_label": "Armed Forces",
"answer_options": {
"0": "A current or former regular in the UK Armed Forces (exc. National Service)",
"1": "A current or former reserve 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 (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",
"3": "No",
"4": "Tenant prefers not to say"
},
"conditional_for": {
"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": [
"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",
"age1": 35,
"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",
"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",
"other_hhmemb": 7,
"relat2": "Partner",
@ -389,9 +389,9 @@
"type": "string",
"minLength": 1,
"enum": [
"White: English/Scottish/Welsh/Northern Irish/British",
"White: English, Welsh, Scottish, Northern Irish or British",
"White: Irish",
"White: Gypsy/Irish Traveller",
"White: Gypsy or Irish Traveller",
"White: Other",
"Mixed: White and Black Caribbean",
"Mixed: White and Black African",
@ -415,7 +415,7 @@
"minLength": 1,
"enum": [
"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",
"Czech Republic",
"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
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
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")
choose("case-log-reservist-no-field", allow_label_click: true)
expect(page).to have_checked_field("case-log-reservist-no-field", visible: false)
choose("case-log-armedforces-no-field", allow_label_click: true)
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)
end
end

6
spec/fixtures/complete_case_log.json vendored

@ -3,11 +3,11 @@
"tenant_code": "T657",
"age1": 35,
"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",
"prevten": "Private sector tenancy",
"armedforces": "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 (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 (excluding National Service)",
"armed_forces_partner": "",
"ecstat1": "Full-time - 30 hours or more",
"other_hhmemb": 7,

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

@ -117,15 +117,15 @@
"type": "radio",
"check_answer_label": "Armed Forces",
"answer_options": {
"0":"A current or former regular in the UK Armed Forces (exc. National Service)",
"1":"A current or former reserve 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 (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",
"3": "No",
"4": "Tenant prefers not to say"
},
"conditional_for": {
"leftreg": ["A current or former regular in the UK Armed Forces (exc. National Service)"],
"reservist": ["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 (excluding National Service)"]
}
},
"leftreg": {

6
spec/models/case_log_spec.rb

@ -185,7 +185,7 @@ RSpec.describe Form, type: :model do
context "armed forces injured validation" do
it "must be answered if tenant was a regular or reserve in armed forces" do
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,
owning_organisation: owning_organisation,
managing_organisation: managing_organisation)
@ -507,7 +507,7 @@ RSpec.describe Form, type: :model do
context "armed forces active validation" do
it "must be answered if ever served in the forces as a regular" do
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,
owning_organisation: owning_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
it "must be answered if ever served in the forces as a regular" 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",
reservist: "Yes",
owning_organisation: owning_organisation,

Loading…
Cancel
Save