From 580a46c119b79224ced88d75561e015b3bb06804 Mon Sep 17 00:00:00 2001 From: Katherine Langford Date: Thu, 22 Jan 2026 18:00:34 +0000 Subject: [PATCH] CLDC-4177: Converts new field to lowercase --- .../pages/person_sex_registered_at_birth.rb | 4 +-- .../sales/pages/sex_registered_at_birth2.rb | 2 +- .../person_sex_registered_at_birth.rb | 2 +- .../questions/sex_registered_at_birth1.rb | 2 +- .../questions/sex_registered_at_birth2.rb | 6 ++-- app/services/csv/sales_log_csv_service.rb | 2 +- .../sales/household_characteristics.en.yml | 12 +++---- ...d_sex_registered_at_birth_to_sales_logs.rb | 12 +++---- db/schema.rb | 12 +++---- .../person_sex_registered_at_birth_spec.rb | 10 +++--- .../pages/sex_registered_at_birth1_spec.rb | 2 +- .../pages/sex_registered_at_birth2_spec.rb | 2 +- .../person_sex_registered_at_birth_spec.rb | 32 +++++++++---------- .../sex_registered_at_birth1_spec.rb | 2 +- .../sex_registered_at_birth2_spec.rb | 4 +-- 15 files changed, 53 insertions(+), 53 deletions(-) diff --git a/app/models/form/sales/pages/person_sex_registered_at_birth.rb b/app/models/form/sales/pages/person_sex_registered_at_birth.rb index 495513766..807afe9b0 100644 --- a/app/models/form/sales/pages/person_sex_registered_at_birth.rb +++ b/app/models/form/sales/pages/person_sex_registered_at_birth.rb @@ -3,7 +3,7 @@ class Form::Sales::Pages::PersonSexRegisteredAtBirth < ::Form::Page def initialize(id, hsh, subsection, person_index:) super(id, hsh, subsection) - @copy_key = "sales.household_characteristics.sexRAB2.person" if person_index == 2 + @copy_key = "sales.household_characteristics.sexrab2.person" if person_index == 2 @person_index = person_index @depends_on = [ { "details_known_#{person_index}" => 1 }, @@ -12,7 +12,7 @@ class Form::Sales::Pages::PersonSexRegisteredAtBirth < ::Form::Page def questions @questions ||= [ - Form::Sales::Questions::PersonSexRegisteredAtBirth.new("sexRAB#{@person_index}", nil, self, person_index: @person_index), + Form::Sales::Questions::PersonSexRegisteredAtBirth.new("sexrab#{@person_index}", nil, self, person_index: @person_index), ] end end diff --git a/app/models/form/sales/pages/sex_registered_at_birth2.rb b/app/models/form/sales/pages/sex_registered_at_birth2.rb index e453e2f39..74cf4034c 100644 --- a/app/models/form/sales/pages/sex_registered_at_birth2.rb +++ b/app/models/form/sales/pages/sex_registered_at_birth2.rb @@ -4,7 +4,7 @@ class Form::Sales::Pages::SexRegisteredAtBirth2 < ::Form::Page def initialize(id, hsh, subsection) super @id = "buyer_2_sex_registered_at_birth" - @copy_key = "sales.household_characteristics.sexRAB2.buyer" + @copy_key = "sales.household_characteristics.sexrab2.buyer" @depends_on = [ { "joint_purchase?" => true, diff --git a/app/models/form/sales/questions/person_sex_registered_at_birth.rb b/app/models/form/sales/questions/person_sex_registered_at_birth.rb index 12079761d..fdc5ce3db 100644 --- a/app/models/form/sales/questions/person_sex_registered_at_birth.rb +++ b/app/models/form/sales/questions/person_sex_registered_at_birth.rb @@ -4,7 +4,7 @@ class Form::Sales::Questions::PersonSexRegisteredAtBirth < ::Form::Question def initialize(id, hsh, page, person_index:) super(id, hsh, page) @type = "radio" - @copy_key = "sales.household_characteristics.sexRAB2.person" if person_index == 2 + @copy_key = "sales.household_characteristics.sexrab2.person" if person_index == 2 @check_answers_card_number = person_index @inferred_check_answers_value = [{ "condition" => { diff --git a/app/models/form/sales/questions/sex_registered_at_birth1.rb b/app/models/form/sales/questions/sex_registered_at_birth1.rb index f6b219d74..a1a659753 100644 --- a/app/models/form/sales/questions/sex_registered_at_birth1.rb +++ b/app/models/form/sales/questions/sex_registered_at_birth1.rb @@ -3,7 +3,7 @@ class Form::Sales::Questions::SexRegisteredAtBirth1 < ::Form::Question def initialize(id, hsh, page) super - @id = "sexRAB1" + @id = "sexrab1" @type = "radio" @check_answers_card_number = 1 @answer_options = ANSWER_OPTIONS diff --git a/app/models/form/sales/questions/sex_registered_at_birth2.rb b/app/models/form/sales/questions/sex_registered_at_birth2.rb index 23af640c8..45edb3775 100644 --- a/app/models/form/sales/questions/sex_registered_at_birth2.rb +++ b/app/models/form/sales/questions/sex_registered_at_birth2.rb @@ -3,13 +3,13 @@ class Form::Sales::Questions::SexRegisteredAtBirth2 < ::Form::Question def initialize(id, hsh, page) super - @id = "sexRAB2" + @id = "sexrab2" @type = "radio" - @copy_key = "sales.household_characteristics.sexRAB2.buyer" + @copy_key = "sales.household_characteristics.sexrab2.buyer" @check_answers_card_number = 2 @inferred_check_answers_value = [{ "condition" => { - "sexRAB2" => "R", + "sexrab2" => "R", }, "value" => "Buyer prefers not to say", }] diff --git a/app/services/csv/sales_log_csv_service.rb b/app/services/csv/sales_log_csv_service.rb index b5291b0f9..ed16653f1 100644 --- a/app/services/csv/sales_log_csv_service.rb +++ b/app/services/csv/sales_log_csv_service.rb @@ -114,7 +114,7 @@ module Csv hash["age1"] = { "refused_code" => "-9", "refused_label" => "Not known", "age_known_field" => "age1_known" } (2..6).each do |i| hash["age#{i}"] = { "refused_code" => "-9", "refused_label" => "Not known", "details_known_field" => "details_known_#{i}", "age_known_field" => "age#{i}_known" } - hash["sexRAB#{i}"] = { "refused_code" => "R", "refused_label" => "Prefers not to say", "details_known_field" => "details_known_#{i}" } + hash["sexrab#{i}"] = { "refused_code" => "R", "refused_label" => "Prefers not to say", "details_known_field" => "details_known_#{i}" } hash["sex#{i}"] = { "refused_code" => "R", "refused_label" => "Prefers not to say", "details_known_field" => "details_known_#{i}" } hash["relat#{i}"] = { "refused_code" => "R", "refused_label" => "Prefers not to say", "details_known_field" => "details_known_#{i}" } hash["ecstat#{i}"] = { "refused_code" => "10", "refused_label" => "Prefers not to say", "details_known_field" => "details_known_#{i}" } diff --git a/config/locales/forms/2026/sales/household_characteristics.en.yml b/config/locales/forms/2026/sales/household_characteristics.en.yml index 534ee747a..4bdb07670 100644 --- a/config/locales/forms/2026/sales/household_characteristics.en.yml +++ b/config/locales/forms/2026/sales/household_characteristics.en.yml @@ -16,7 +16,7 @@ en: hint_text: "" question_text: "Age" - sexRAB1: + sexrab1: page_header: "" check_answer_label: "Buyer 1’s sex registered at birth" check_answer_prompt: "" @@ -137,7 +137,7 @@ en: hint_text: "" question_text: "Age" - sexRAB2: + sexrab2: buyer: page_header: "" check_answer_label: "Buyer 2’s sex registered at birth" @@ -287,7 +287,7 @@ en: hint_text: "" question_text: "Age" - sexRAB3: + sexrab3: page_header: "" check_answer_label: "Person 3’s sex registered at birth" check_answer_prompt: "" @@ -335,7 +335,7 @@ en: hint_text: "" question_text: "Age" - sexRAB4: + sexrab4: page_header: "" check_answer_label: "Person 4’s sex registered at birth" check_answer_prompt: "" @@ -383,7 +383,7 @@ en: hint_text: "" question_text: "Age" - sexRAB5: + sexrab5: page_header: "" check_answer_label: "Person 5’s sex registered at birth" check_answer_prompt: "" @@ -431,7 +431,7 @@ en: hint_text: "" question_text: "Age" - sexRAB6: + sexrab6: page_header: "" check_answer_label: "Person 6’s sex registered at birth" check_answer_prompt: "" diff --git a/db/migrate/20260113143404_add_sex_registered_at_birth_to_sales_logs.rb b/db/migrate/20260113143404_add_sex_registered_at_birth_to_sales_logs.rb index c245d1d51..27273b566 100644 --- a/db/migrate/20260113143404_add_sex_registered_at_birth_to_sales_logs.rb +++ b/db/migrate/20260113143404_add_sex_registered_at_birth_to_sales_logs.rb @@ -1,12 +1,12 @@ class AddSexRegisteredAtBirthToSalesLogs < ActiveRecord::Migration[7.2] def change change_table :sales_logs, bulk: true do |t| - t.column :sexRAB1, :string - t.column :sexRAB2, :string - t.column :sexRAB3, :string - t.column :sexRAB4, :string - t.column :sexRAB5, :string - t.column :sexRAB6, :string + t.column :sexrab1, :string + t.column :sexrab2, :string + t.column :sexrab3, :string + t.column :sexrab4, :string + t.column :sexrab5, :string + t.column :sexrab6, :string end end end diff --git a/db/schema.rb b/db/schema.rb index 99b47a365..d8d145162 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -787,12 +787,12 @@ ActiveRecord::Schema[7.2].define(version: 2026_01_13_143404) do t.datetime "lasttransaction" t.datetime "initialpurchase" t.boolean "manual_address_entry_selected", default: false - t.string "sexRAB1" - t.string "sexRAB2" - t.string "sexRAB3" - t.string "sexRAB4" - t.string "sexRAB5" - t.string "sexRAB6" + t.string "sexrab1" + t.string "sexrab2" + t.string "sexrab3" + t.string "sexrab4" + t.string "sexrab5" + t.string "sexrab6" t.index ["assigned_to_id"], name: "index_sales_logs_on_assigned_to_id" t.index ["bulk_upload_id"], name: "index_sales_logs_on_bulk_upload_id" t.index ["created_by_id"], name: "index_sales_logs_on_created_by_id" diff --git a/spec/models/form/sales/pages/person_sex_registered_at_birth_spec.rb b/spec/models/form/sales/pages/person_sex_registered_at_birth_spec.rb index 0885e1d3e..fa116818c 100644 --- a/spec/models/form/sales/pages/person_sex_registered_at_birth_spec.rb +++ b/spec/models/form/sales/pages/person_sex_registered_at_birth_spec.rb @@ -22,7 +22,7 @@ RSpec.describe Form::Sales::Pages::PersonSexRegisteredAtBirth, type: :model do let(:page_id) { "person_2_sex_registered_at_birth" } it "has correct questions" do - expect(page.questions.map(&:id)).to eq(%w[sexRAB2]) + expect(page.questions.map(&:id)).to eq(%w[sexrab2]) end it "has the correct id" do @@ -39,7 +39,7 @@ RSpec.describe Form::Sales::Pages::PersonSexRegisteredAtBirth, type: :model do let(:page_id) { "person_3_sex_registered_at_birth" } it "has correct questions" do - expect(page.questions.map(&:id)).to eq(%w[sexRAB3]) + expect(page.questions.map(&:id)).to eq(%w[sexrab3]) end it "has the correct id" do @@ -56,7 +56,7 @@ RSpec.describe Form::Sales::Pages::PersonSexRegisteredAtBirth, type: :model do let(:page_id) { "person_4_sex_registered_at_birth" } it "has correct questions" do - expect(page.questions.map(&:id)).to eq(%w[sexRAB4]) + expect(page.questions.map(&:id)).to eq(%w[sexrab4]) end it "has the correct id" do @@ -73,7 +73,7 @@ RSpec.describe Form::Sales::Pages::PersonSexRegisteredAtBirth, type: :model do let(:page_id) { "person_5_sex_registered_at_birth" } it "has correct questions" do - expect(page.questions.map(&:id)).to eq(%w[sexRAB5]) + expect(page.questions.map(&:id)).to eq(%w[sexrab5]) end it "has the correct id" do @@ -90,7 +90,7 @@ RSpec.describe Form::Sales::Pages::PersonSexRegisteredAtBirth, type: :model do let(:page_id) { "person_6_sex_registered_at_birth" } it "has correct questions" do - expect(page.questions.map(&:id)).to eq(%w[sexRAB6]) + expect(page.questions.map(&:id)).to eq(%w[sexrab6]) end it "has the correct id" do diff --git a/spec/models/form/sales/pages/sex_registered_at_birth1_spec.rb b/spec/models/form/sales/pages/sex_registered_at_birth1_spec.rb index 2339a1064..da020aa91 100644 --- a/spec/models/form/sales/pages/sex_registered_at_birth1_spec.rb +++ b/spec/models/form/sales/pages/sex_registered_at_birth1_spec.rb @@ -12,7 +12,7 @@ RSpec.describe Form::Sales::Pages::SexRegisteredAtBirth1, type: :model do end it "has correct questions" do - expect(page.questions.map(&:id)).to eq(%w[sexRAB1]) + expect(page.questions.map(&:id)).to eq(%w[sexrab1]) end it "has the correct id" do diff --git a/spec/models/form/sales/pages/sex_registered_at_birth2_spec.rb b/spec/models/form/sales/pages/sex_registered_at_birth2_spec.rb index cb1a20cdd..d120c6e23 100644 --- a/spec/models/form/sales/pages/sex_registered_at_birth2_spec.rb +++ b/spec/models/form/sales/pages/sex_registered_at_birth2_spec.rb @@ -12,7 +12,7 @@ RSpec.describe Form::Sales::Pages::SexRegisteredAtBirth2, type: :model do end it "has correct questions" do - expect(page.questions.map(&:id)).to eq(%w[sexRAB2]) + expect(page.questions.map(&:id)).to eq(%w[sexrab2]) end it "has the correct id" do diff --git a/spec/models/form/sales/questions/person_sex_registered_at_birth_spec.rb b/spec/models/form/sales/questions/person_sex_registered_at_birth_spec.rb index 804a390c2..2f51fa8c4 100644 --- a/spec/models/form/sales/questions/person_sex_registered_at_birth_spec.rb +++ b/spec/models/form/sales/questions/person_sex_registered_at_birth_spec.rb @@ -3,7 +3,7 @@ require "rails_helper" RSpec.describe Form::Sales::Questions::PersonSexRegisteredAtBirth, type: :model do subject(:question) { described_class.new(question_id, question_definition, page, person_index:) } - let(:question_id) { "sexRAB2" } + let(:question_id) { "sexrab2" } let(:question_definition) { nil } let(:page) { instance_double(Form::Page) } let(:person_index) { 2 } @@ -37,11 +37,11 @@ RSpec.describe Form::Sales::Questions::PersonSexRegisteredAtBirth, type: :model end context "when person 2" do - let(:question_id) { "sexRAB2" } + let(:question_id) { "sexrab2" } let(:person_index) { 2 } it "has the correct id" do - expect(question.id).to eq("sexRAB2") + expect(question.id).to eq("sexrab2") end it "has expected check answers card number" do @@ -50,17 +50,17 @@ RSpec.describe Form::Sales::Questions::PersonSexRegisteredAtBirth, type: :model it "has the correct inferred_check_answers_value" do expect(question.inferred_check_answers_value).to eq([ - { "condition" => { "sexRAB2" => "R" }, "value" => "Person prefers not to say" }, + { "condition" => { "sexrab2" => "R" }, "value" => "Person prefers not to say" }, ]) end end context "when person 3" do - let(:question_id) { "sexRAB3" } + let(:question_id) { "sexrab3" } let(:person_index) { 3 } it "has the correct id" do - expect(question.id).to eq("sexRAB3") + expect(question.id).to eq("sexrab3") end it "has expected check answers card number" do @@ -69,17 +69,17 @@ RSpec.describe Form::Sales::Questions::PersonSexRegisteredAtBirth, type: :model it "has the correct inferred_check_answers_value" do expect(question.inferred_check_answers_value).to eq([ - { "condition" => { "sexRAB3" => "R" }, "value" => "Person prefers not to say" }, + { "condition" => { "sexrab3" => "R" }, "value" => "Person prefers not to say" }, ]) end end context "when person 4" do - let(:question_id) { "sexRAB4" } + let(:question_id) { "sexrab4" } let(:person_index) { 4 } it "has the correct id" do - expect(question.id).to eq("sexRAB4") + expect(question.id).to eq("sexrab4") end it "has expected check answers card number" do @@ -88,17 +88,17 @@ RSpec.describe Form::Sales::Questions::PersonSexRegisteredAtBirth, type: :model it "has the correct inferred_check_answers_value" do expect(question.inferred_check_answers_value).to eq([ - { "condition" => { "sexRAB4" => "R" }, "value" => "Person prefers not to say" }, + { "condition" => { "sexrab4" => "R" }, "value" => "Person prefers not to say" }, ]) end end context "when person 5" do - let(:question_id) { "sexRAB5" } + let(:question_id) { "sexrab5" } let(:person_index) { 5 } it "has the correct id" do - expect(question.id).to eq("sexRAB5") + expect(question.id).to eq("sexrab5") end it "has expected check answers card number" do @@ -107,17 +107,17 @@ RSpec.describe Form::Sales::Questions::PersonSexRegisteredAtBirth, type: :model it "has the correct inferred_check_answers_value" do expect(question.inferred_check_answers_value).to eq([ - { "condition" => { "sexRAB5" => "R" }, "value" => "Person prefers not to say" }, + { "condition" => { "sexrab5" => "R" }, "value" => "Person prefers not to say" }, ]) end end context "when person 6" do - let(:question_id) { "sexRAB6" } + let(:question_id) { "sexrab6" } let(:person_index) { 6 } it "has the correct id" do - expect(question.id).to eq("sexRAB6") + expect(question.id).to eq("sexrab6") end it "has expected check answers card number" do @@ -126,7 +126,7 @@ RSpec.describe Form::Sales::Questions::PersonSexRegisteredAtBirth, type: :model it "has the correct inferred_check_answers_value" do expect(question.inferred_check_answers_value).to eq([ - { "condition" => { "sexRAB6" => "R" }, "value" => "Person prefers not to say" }, + { "condition" => { "sexrab6" => "R" }, "value" => "Person prefers not to say" }, ]) end end diff --git a/spec/models/form/sales/questions/sex_registered_at_birth1_spec.rb b/spec/models/form/sales/questions/sex_registered_at_birth1_spec.rb index b6e0a216f..0b3661ad6 100644 --- a/spec/models/form/sales/questions/sex_registered_at_birth1_spec.rb +++ b/spec/models/form/sales/questions/sex_registered_at_birth1_spec.rb @@ -19,7 +19,7 @@ RSpec.describe Form::Sales::Questions::SexRegisteredAtBirth1, type: :model do end it "has the correct id" do - expect(question.id).to eq("sexRAB1") + expect(question.id).to eq("sexrab1") end it "has the correct type" do diff --git a/spec/models/form/sales/questions/sex_registered_at_birth2_spec.rb b/spec/models/form/sales/questions/sex_registered_at_birth2_spec.rb index bad96fc20..ed0d0bc61 100644 --- a/spec/models/form/sales/questions/sex_registered_at_birth2_spec.rb +++ b/spec/models/form/sales/questions/sex_registered_at_birth2_spec.rb @@ -19,7 +19,7 @@ RSpec.describe Form::Sales::Questions::SexRegisteredAtBirth2, type: :model do end it "has the correct id" do - expect(question.id).to eq("sexRAB2") + expect(question.id).to eq("sexrab2") end it "has the correct type" do @@ -45,7 +45,7 @@ RSpec.describe Form::Sales::Questions::SexRegisteredAtBirth2, type: :model do it "has the correct inferred_check_answers_value" do expect(question.inferred_check_answers_value).to eq([ - { "condition" => { "sexRAB2" => "R" }, "value" => "Buyer prefers not to say" }, + { "condition" => { "sexrab2" => "R" }, "value" => "Buyer prefers not to say" }, ]) end end