diff --git a/app/constants/ethnic.rb b/app/constants/ethnic.rb new file mode 100644 index 000000000..5b966311e --- /dev/null +++ b/app/constants/ethnic.rb @@ -0,0 +1,27 @@ +module Ethnic + @@ethnic = { + "White: English/Scottish/Welsh/Northern Irish/British" => 1, + "White: Irish" => 2, + "White: Gypsy/Irish Traveller" => 18, + "White: Other" => 3, + "Mixed: White & Black Caribbean" => 4, + "Mixed: White & Black African" => 5, + "Mixed: White & Asian" => 6, + "Mixed: Other" => 7, + "Asian or Asian British: Indian" => 8, + "Asian or Asian British: Pakistani" => 9, + "Asian or Asian British: Bangladeshi" => 10, + "Asian or Asian British: Chinese" => 15, + "Asian or Asian British: Other" => 11, + "Black: Caribbean" => 12, + "Black: African" => 13, + "Black: Other" => 14, + "Other Ethnic Group: Arab" => 16, + "Other Ethnic Group: Other" => 19, + "Prefer not to say" => 17, + } + + def self.ethnic + @@ethnic + end +end diff --git a/app/constants/national.rb b/app/constants/national.rb new file mode 100644 index 000000000..b01bbd22a --- /dev/null +++ b/app/constants/national.rb @@ -0,0 +1,24 @@ +module National + @@national = { + "UK national resident in UK" => 1, + "A current or former reserve in the UK Armed Forces (exc. National Service)" => 100, + "UK national returning from residence overseas" => 2, + "Czech Republic" => 3, + "Estonia" => 4, + "Hungary" => 5, + "Latvia" => 6, + "Lithuania" => 7, + "Poland" => 8, + "Slovakia" => 9, + "Bulgaria" => 14, + "Romania" => 15, + "Ireland" => 17, + "Other EU Economic Area (EEA country)" => 11, + "Any other country" => 12, + "Prefer not to say" => 13, + } + + def self.national + @@national + end +end diff --git a/app/controllers/case_logs_controller.rb b/app/controllers/case_logs_controller.rb index f8bef385a..54923d657 100644 --- a/app/controllers/case_logs_controller.rb +++ b/app/controllers/case_logs_controller.rb @@ -121,7 +121,7 @@ private end def authenticate - http_basic_authenticate_or_request_with name: ENV["API_USER"], password: ENV["API_KEY"] + http_basic_authenticate_or_request_with ethnic: ENV["API_USER"], password: ENV["API_KEY"] end def api_case_log_params diff --git a/app/models/case_log.rb b/app/models/case_log.rb index d8edacea7..b63217970 100644 --- a/app/models/case_log.rb +++ b/app/models/case_log.rb @@ -37,6 +37,8 @@ end class CaseLog < ApplicationRecord include Discard::Model include SoftValidations + include Ethnic + include National default_scope -> { kept } scope :not_completed, -> { where.not(status: "completed") } @@ -47,6 +49,9 @@ class CaseLog < ApplicationRecord enum status: { "not_started" => 0, "in_progress" => 1, "completed" => 2 } + enum ethnic: Ethnic.ethnic + enum national: National.national, _suffix: true + AUTOGENERATED_FIELDS = %w[id status created_at updated_at discarded_at].freeze def self.editable_fields diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 343307b55..90e4b9574 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -4,9 +4,9 @@ DLUHC CORE Data Collection <%= csrf_meta_tags %> <%= csp_meta_tag %> - <%= tag :meta, name: 'viewport', content: 'width=device-width, initial-scale=1' %> + <%= tag :meta, ethnic: 'viewport', content: 'width=device-width, initial-scale=1' %> <%= tag :meta, property: 'og:image', content: asset_pack_path('media/images/govuk-opengraph-image.png') %> - <%= tag :meta, name: 'theme-color', content: '#0b0c0c' %> + <%= tag :meta, ethnic: 'theme-color', content: '#0b0c0c' %> <%= favicon_link_tag asset_pack_path('media/images/favicon.ico') %> <%= favicon_link_tag asset_pack_path('media/images/govuk-mask-icon.svg'), rel: 'mask-icon', type: 'image/svg', color: "#0b0c0c" %> <%= favicon_link_tag asset_pack_path('media/images/govuk-apple-touch-icon.png'), rel: 'apple-touch-icon', type: 'image/png' %> diff --git a/config/forms/2021_2022.json b/config/forms/2021_2022.json index 3db9c89eb..884234a3b 100644 --- a/config/forms/2021_2022.json +++ b/config/forms/2021_2022.json @@ -64,9 +64,9 @@ "hint_text": "", "type": "radio", "answer_options": { - "0": "White: English/Scottish/Welsh/Northern Irish/British", - "1": "White: Irish", - "2": "White: Gypsy/Irish Traveller", + "1": "White: English/Scottish/Welsh/Northern Irish/British", + "2": "White: Irish", + "18": "White: Gypsy/Irish Traveller", "3": "White: Other", "4": "Mixed: White & Black Caribbean", "5": "Mixed: White & Black African", @@ -75,14 +75,14 @@ "8": "Asian or Asian British: Indian", "9": "Asian or Asian British: Pakistani", "10": "Asian or Asian British: Bangladeshi", - "11": "Asian or Asian British: Chinese", - "12": "Asian or Asian British: Other", - "13": "Black: Caribbean", - "14": "Black: African", - "15": "Black: Other", + "15": "Asian or Asian British: Chinese", + "11": "Asian or Asian British: Other", + "12": "Black: Caribbean", + "13": "Black: African", + "14": "Black: Other", "16": "Other Ethnic Group: Arab", - "17": "Other Ethnic Group: Other", - "18": "Prefer not to say" + "19": "Other Ethnic Group: Other", + "17": "Prefer not to say" } } } @@ -97,8 +97,8 @@ "hint_text": "", "type": "radio", "answer_options": { - "0": "UK national resident in UK", - "1": "A current or former reserve in the UK Armed Forces (exc. National Service)", + "1": "UK national resident in UK", + "100": "A current or former reserve in the UK Armed Forces (exc. National Service)", "2": "UK national returning from residence overseas", "3": "Czech Republic", "4": "Estonia", @@ -107,12 +107,12 @@ "7": "Lithuania", "8": "Poland", "9": "Slovakia", - "10": "Bulgaria", - "11": "Romania", - "12": "Ireland", - "13": "Other EU Economic Area (EEA country)", - "14": "Any other country", - "15": "Prefer not to say" + "14": "Bulgaria", + "15": "Romania", + "17": "Ireland", + "11": "Other EU Economic Area (EEA country)", + "12": "Any other country", + "13": "Prefer not to say" } } } diff --git a/db/migrate/20211101192151_rename_fields.rb b/db/migrate/20211101192151_rename_fields.rb index e11b65042..59e103f3e 100644 --- a/db/migrate/20211101192151_rename_fields.rb +++ b/db/migrate/20211101192151_rename_fields.rb @@ -102,6 +102,5 @@ class RenameFields < ActiveRecord::Migration[6.1] rename_column :case_logs, :cbl_letting, :cbl rename_column :case_logs, :chr_letting, :chr rename_column :case_logs, :cap_letting, :cap - end end diff --git a/db/migrate/20211103090530_change_field_types.rb b/db/migrate/20211103090530_change_field_types.rb new file mode 100644 index 000000000..33d308c8b --- /dev/null +++ b/db/migrate/20211103090530_change_field_types.rb @@ -0,0 +1,15 @@ +class ChangeFieldTypes < ActiveRecord::Migration[6.1] + def up + change_table :case_logs, bulk: true do |t| + t.change :ethnic, "integer USING ethnic::integer" + t.change :national, "integer USING national::integer" + end + end + + def down + change_table :case_logs, bulk: true do |t| + t.change :ethnic, :string + t.change :national, :string + end + end +end diff --git a/db/schema.rb b/db/schema.rb index 537866e52..3fcb1a8e9 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 2021_11_01_192151) do +ActiveRecord::Schema.define(version: 2021_11_03_090530) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -22,7 +22,7 @@ ActiveRecord::Schema.define(version: 2021_11_01_192151) do t.string "tenant_code" t.integer "age1" t.string "sex1" - t.string "ethnic" + t.integer "ethnic" t.string "national" t.string "prevten" t.string "armed_forces" @@ -135,7 +135,7 @@ ActiveRecord::Schema.define(version: 2021_11_01_192151) do t.boolean "override_net_income_validation" t.string "tenancyother" t.string "net_income_known" - t.index ["discarded_at"], name: "index_case_logs_on_discarded_at" + t.index ["discarded_at"], ethnic: "index_case_logs_on_discarded_at" end end diff --git a/spec/features/case_log_spec.rb b/spec/features/case_log_spec.rb index 273daeb4a..2af5e0504 100644 --- a/spec/features/case_log_spec.rb +++ b/spec/features/case_log_spec.rb @@ -223,7 +223,7 @@ RSpec.describe "Test Features" do describe "Form flow is correct" do context "given an ordered list of pages" do it "leads to the next one in the correct order" do - pages = question_answers.map {|_key, val| val[:path]} + pages = question_answers.map { |_key, val| val[:path] } pages[0..-2].each_with_index do |val, index| visit("/case_logs/#{id}/#{val}") click_button("Save and continue")