Browse Source

CLDC-4177: Converts new field to lowercase

CLDC-4177-sales-sab-question
Katherine Langford 2 weeks ago
parent
commit
580a46c119
  1. 4
      app/models/form/sales/pages/person_sex_registered_at_birth.rb
  2. 2
      app/models/form/sales/pages/sex_registered_at_birth2.rb
  3. 2
      app/models/form/sales/questions/person_sex_registered_at_birth.rb
  4. 2
      app/models/form/sales/questions/sex_registered_at_birth1.rb
  5. 6
      app/models/form/sales/questions/sex_registered_at_birth2.rb
  6. 2
      app/services/csv/sales_log_csv_service.rb
  7. 12
      config/locales/forms/2026/sales/household_characteristics.en.yml
  8. 12
      db/migrate/20260113143404_add_sex_registered_at_birth_to_sales_logs.rb
  9. 12
      db/schema.rb
  10. 10
      spec/models/form/sales/pages/person_sex_registered_at_birth_spec.rb
  11. 2
      spec/models/form/sales/pages/sex_registered_at_birth1_spec.rb
  12. 2
      spec/models/form/sales/pages/sex_registered_at_birth2_spec.rb
  13. 32
      spec/models/form/sales/questions/person_sex_registered_at_birth_spec.rb
  14. 2
      spec/models/form/sales/questions/sex_registered_at_birth1_spec.rb
  15. 4
      spec/models/form/sales/questions/sex_registered_at_birth2_spec.rb

4
app/models/form/sales/pages/person_sex_registered_at_birth.rb

@ -3,7 +3,7 @@
class Form::Sales::Pages::PersonSexRegisteredAtBirth < ::Form::Page class Form::Sales::Pages::PersonSexRegisteredAtBirth < ::Form::Page
def initialize(id, hsh, subsection, person_index:) def initialize(id, hsh, subsection, person_index:)
super(id, hsh, subsection) 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 @person_index = person_index
@depends_on = [ @depends_on = [
{ "details_known_#{person_index}" => 1 }, { "details_known_#{person_index}" => 1 },
@ -12,7 +12,7 @@ class Form::Sales::Pages::PersonSexRegisteredAtBirth < ::Form::Page
def questions def questions
@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
end end

2
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) def initialize(id, hsh, subsection)
super super
@id = "buyer_2_sex_registered_at_birth" @id = "buyer_2_sex_registered_at_birth"
@copy_key = "sales.household_characteristics.sexRAB2.buyer" @copy_key = "sales.household_characteristics.sexrab2.buyer"
@depends_on = [ @depends_on = [
{ {
"joint_purchase?" => true, "joint_purchase?" => true,

2
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:) def initialize(id, hsh, page, person_index:)
super(id, hsh, page) super(id, hsh, page)
@type = "radio" @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 @check_answers_card_number = person_index
@inferred_check_answers_value = [{ @inferred_check_answers_value = [{
"condition" => { "condition" => {

2
app/models/form/sales/questions/sex_registered_at_birth1.rb

@ -3,7 +3,7 @@
class Form::Sales::Questions::SexRegisteredAtBirth1 < ::Form::Question class Form::Sales::Questions::SexRegisteredAtBirth1 < ::Form::Question
def initialize(id, hsh, page) def initialize(id, hsh, page)
super super
@id = "sexRAB1" @id = "sexrab1"
@type = "radio" @type = "radio"
@check_answers_card_number = 1 @check_answers_card_number = 1
@answer_options = ANSWER_OPTIONS @answer_options = ANSWER_OPTIONS

6
app/models/form/sales/questions/sex_registered_at_birth2.rb

@ -3,13 +3,13 @@
class Form::Sales::Questions::SexRegisteredAtBirth2 < ::Form::Question class Form::Sales::Questions::SexRegisteredAtBirth2 < ::Form::Question
def initialize(id, hsh, page) def initialize(id, hsh, page)
super super
@id = "sexRAB2" @id = "sexrab2"
@type = "radio" @type = "radio"
@copy_key = "sales.household_characteristics.sexRAB2.buyer" @copy_key = "sales.household_characteristics.sexrab2.buyer"
@check_answers_card_number = 2 @check_answers_card_number = 2
@inferred_check_answers_value = [{ @inferred_check_answers_value = [{
"condition" => { "condition" => {
"sexRAB2" => "R", "sexrab2" => "R",
}, },
"value" => "Buyer prefers not to say", "value" => "Buyer prefers not to say",
}] }]

2
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" } hash["age1"] = { "refused_code" => "-9", "refused_label" => "Not known", "age_known_field" => "age1_known" }
(2..6).each do |i| (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["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["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["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}" } hash["ecstat#{i}"] = { "refused_code" => "10", "refused_label" => "Prefers not to say", "details_known_field" => "details_known_#{i}" }

12
config/locales/forms/2026/sales/household_characteristics.en.yml

@ -16,7 +16,7 @@ en:
hint_text: "" hint_text: ""
question_text: "Age" question_text: "Age"
sexRAB1: sexrab1:
page_header: "" page_header: ""
check_answer_label: "Buyer 1’s sex registered at birth" check_answer_label: "Buyer 1’s sex registered at birth"
check_answer_prompt: "" check_answer_prompt: ""
@ -137,7 +137,7 @@ en:
hint_text: "" hint_text: ""
question_text: "Age" question_text: "Age"
sexRAB2: sexrab2:
buyer: buyer:
page_header: "" page_header: ""
check_answer_label: "Buyer 2’s sex registered at birth" check_answer_label: "Buyer 2’s sex registered at birth"
@ -287,7 +287,7 @@ en:
hint_text: "" hint_text: ""
question_text: "Age" question_text: "Age"
sexRAB3: sexrab3:
page_header: "" page_header: ""
check_answer_label: "Person 3’s sex registered at birth" check_answer_label: "Person 3’s sex registered at birth"
check_answer_prompt: "" check_answer_prompt: ""
@ -335,7 +335,7 @@ en:
hint_text: "" hint_text: ""
question_text: "Age" question_text: "Age"
sexRAB4: sexrab4:
page_header: "" page_header: ""
check_answer_label: "Person 4’s sex registered at birth" check_answer_label: "Person 4’s sex registered at birth"
check_answer_prompt: "" check_answer_prompt: ""
@ -383,7 +383,7 @@ en:
hint_text: "" hint_text: ""
question_text: "Age" question_text: "Age"
sexRAB5: sexrab5:
page_header: "" page_header: ""
check_answer_label: "Person 5’s sex registered at birth" check_answer_label: "Person 5’s sex registered at birth"
check_answer_prompt: "" check_answer_prompt: ""
@ -431,7 +431,7 @@ en:
hint_text: "" hint_text: ""
question_text: "Age" question_text: "Age"
sexRAB6: sexrab6:
page_header: "" page_header: ""
check_answer_label: "Person 6’s sex registered at birth" check_answer_label: "Person 6’s sex registered at birth"
check_answer_prompt: "" check_answer_prompt: ""

12
db/migrate/20260113143404_add_sex_registered_at_birth_to_sales_logs.rb

@ -1,12 +1,12 @@
class AddSexRegisteredAtBirthToSalesLogs < ActiveRecord::Migration[7.2] class AddSexRegisteredAtBirthToSalesLogs < ActiveRecord::Migration[7.2]
def change def change
change_table :sales_logs, bulk: true do |t| change_table :sales_logs, bulk: true do |t|
t.column :sexRAB1, :string t.column :sexrab1, :string
t.column :sexRAB2, :string t.column :sexrab2, :string
t.column :sexRAB3, :string t.column :sexrab3, :string
t.column :sexRAB4, :string t.column :sexrab4, :string
t.column :sexRAB5, :string t.column :sexrab5, :string
t.column :sexRAB6, :string t.column :sexrab6, :string
end end
end end
end end

12
db/schema.rb

@ -787,12 +787,12 @@ ActiveRecord::Schema[7.2].define(version: 2026_01_13_143404) do
t.datetime "lasttransaction" t.datetime "lasttransaction"
t.datetime "initialpurchase" t.datetime "initialpurchase"
t.boolean "manual_address_entry_selected", default: false t.boolean "manual_address_entry_selected", default: false
t.string "sexRAB1" t.string "sexrab1"
t.string "sexRAB2" t.string "sexrab2"
t.string "sexRAB3" t.string "sexrab3"
t.string "sexRAB4" t.string "sexrab4"
t.string "sexRAB5" t.string "sexrab5"
t.string "sexRAB6" t.string "sexrab6"
t.index ["assigned_to_id"], name: "index_sales_logs_on_assigned_to_id" 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 ["bulk_upload_id"], name: "index_sales_logs_on_bulk_upload_id"
t.index ["created_by_id"], name: "index_sales_logs_on_created_by_id" t.index ["created_by_id"], name: "index_sales_logs_on_created_by_id"

10
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" } let(:page_id) { "person_2_sex_registered_at_birth" }
it "has correct questions" do it "has correct questions" do
expect(page.questions.map(&:id)).to eq(%w[sexRAB2]) expect(page.questions.map(&:id)).to eq(%w[sexrab2])
end end
it "has the correct id" do 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" } let(:page_id) { "person_3_sex_registered_at_birth" }
it "has correct questions" do it "has correct questions" do
expect(page.questions.map(&:id)).to eq(%w[sexRAB3]) expect(page.questions.map(&:id)).to eq(%w[sexrab3])
end end
it "has the correct id" do 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" } let(:page_id) { "person_4_sex_registered_at_birth" }
it "has correct questions" do it "has correct questions" do
expect(page.questions.map(&:id)).to eq(%w[sexRAB4]) expect(page.questions.map(&:id)).to eq(%w[sexrab4])
end end
it "has the correct id" do 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" } let(:page_id) { "person_5_sex_registered_at_birth" }
it "has correct questions" do it "has correct questions" do
expect(page.questions.map(&:id)).to eq(%w[sexRAB5]) expect(page.questions.map(&:id)).to eq(%w[sexrab5])
end end
it "has the correct id" do 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" } let(:page_id) { "person_6_sex_registered_at_birth" }
it "has correct questions" do it "has correct questions" do
expect(page.questions.map(&:id)).to eq(%w[sexRAB6]) expect(page.questions.map(&:id)).to eq(%w[sexrab6])
end end
it "has the correct id" do it "has the correct id" do

2
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 end
it "has correct questions" do it "has correct questions" do
expect(page.questions.map(&:id)).to eq(%w[sexRAB1]) expect(page.questions.map(&:id)).to eq(%w[sexrab1])
end end
it "has the correct id" do it "has the correct id" do

2
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 end
it "has correct questions" do it "has correct questions" do
expect(page.questions.map(&:id)).to eq(%w[sexRAB2]) expect(page.questions.map(&:id)).to eq(%w[sexrab2])
end end
it "has the correct id" do it "has the correct id" do

32
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 RSpec.describe Form::Sales::Questions::PersonSexRegisteredAtBirth, type: :model do
subject(:question) { described_class.new(question_id, question_definition, page, person_index:) } 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(:question_definition) { nil }
let(:page) { instance_double(Form::Page) } let(:page) { instance_double(Form::Page) }
let(:person_index) { 2 } let(:person_index) { 2 }
@ -37,11 +37,11 @@ RSpec.describe Form::Sales::Questions::PersonSexRegisteredAtBirth, type: :model
end end
context "when person 2" do context "when person 2" do
let(:question_id) { "sexRAB2" } let(:question_id) { "sexrab2" }
let(:person_index) { 2 } let(:person_index) { 2 }
it "has the correct id" do it "has the correct id" do
expect(question.id).to eq("sexRAB2") expect(question.id).to eq("sexrab2")
end end
it "has expected check answers card number" do 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 it "has the correct inferred_check_answers_value" do
expect(question.inferred_check_answers_value).to eq([ 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
end end
context "when person 3" do context "when person 3" do
let(:question_id) { "sexRAB3" } let(:question_id) { "sexrab3" }
let(:person_index) { 3 } let(:person_index) { 3 }
it "has the correct id" do it "has the correct id" do
expect(question.id).to eq("sexRAB3") expect(question.id).to eq("sexrab3")
end end
it "has expected check answers card number" do 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 it "has the correct inferred_check_answers_value" do
expect(question.inferred_check_answers_value).to eq([ 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
end end
context "when person 4" do context "when person 4" do
let(:question_id) { "sexRAB4" } let(:question_id) { "sexrab4" }
let(:person_index) { 4 } let(:person_index) { 4 }
it "has the correct id" do it "has the correct id" do
expect(question.id).to eq("sexRAB4") expect(question.id).to eq("sexrab4")
end end
it "has expected check answers card number" do 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 it "has the correct inferred_check_answers_value" do
expect(question.inferred_check_answers_value).to eq([ 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
end end
context "when person 5" do context "when person 5" do
let(:question_id) { "sexRAB5" } let(:question_id) { "sexrab5" }
let(:person_index) { 5 } let(:person_index) { 5 }
it "has the correct id" do it "has the correct id" do
expect(question.id).to eq("sexRAB5") expect(question.id).to eq("sexrab5")
end end
it "has expected check answers card number" do 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 it "has the correct inferred_check_answers_value" do
expect(question.inferred_check_answers_value).to eq([ 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
end end
context "when person 6" do context "when person 6" do
let(:question_id) { "sexRAB6" } let(:question_id) { "sexrab6" }
let(:person_index) { 6 } let(:person_index) { 6 }
it "has the correct id" do it "has the correct id" do
expect(question.id).to eq("sexRAB6") expect(question.id).to eq("sexrab6")
end end
it "has expected check answers card number" do 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 it "has the correct inferred_check_answers_value" do
expect(question.inferred_check_answers_value).to eq([ 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
end end

2
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 end
it "has the correct id" do it "has the correct id" do
expect(question.id).to eq("sexRAB1") expect(question.id).to eq("sexrab1")
end end
it "has the correct type" do it "has the correct type" do

4
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 end
it "has the correct id" do it "has the correct id" do
expect(question.id).to eq("sexRAB2") expect(question.id).to eq("sexrab2")
end end
it "has the correct type" do 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 it "has the correct inferred_check_answers_value" do
expect(question.inferred_check_answers_value).to eq([ 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
end end

Loading…
Cancel
Save