Browse Source

CLDC-3143: Update hint text for gender questions for 2024 (#2220)

* CLDC-3143: Update hint text for gender questions for 2024

* Refactor ifs
pull/2223/head
Rachael Booth 11 months ago committed by GitHub
parent
commit
3a81069bb5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 9
      app/models/form/lettings/questions/gender_identity1.rb
  2. 9
      app/models/form/lettings/questions/person_gender_identity.rb
  3. 9
      app/models/form/sales/questions/gender_identity1.rb
  4. 6
      app/models/form/sales/questions/gender_identity2.rb
  5. 6
      app/models/form/sales/questions/person_gender_identity.rb
  6. 69
      spec/models/form/lettings/questions/gender_identity1_spec.rb
  7. 23
      spec/models/form/lettings/questions/person_gender_identity_spec.rb
  8. 31
      spec/models/form/sales/questions/gender_identity1_spec.rb
  9. 27
      spec/models/form/sales/questions/gender_identity2_spec.rb
  10. 27
      spec/models/form/sales/questions/person_gender_identity_spec.rb

9
app/models/form/lettings/questions/gender_identity1.rb

@ -6,7 +6,6 @@ class Form::Lettings::Questions::GenderIdentity1 < ::Form::Question
@header = "Which of these best describes the lead tenant’s gender identity?"
@type = "radio"
@check_answers_card_number = 1
@hint_text = "The lead tenant is the person in the household who does the most paid work. If several people do the same paid work, the lead tenant is whoever is the oldest."
@answer_options = ANSWER_OPTIONS
@question_number = 33
end
@ -18,4 +17,12 @@ class Form::Lettings::Questions::GenderIdentity1 < ::Form::Question
"divider" => { "value" => true },
"R" => { "value" => "Tenant prefers not to say" },
}.freeze
def hint_text
if form.start_year_after_2024?
"This should be however they personally choose to identify from the options below. This may or may not be the same as their biological sex or the sex they were assigned at birth."
else
"The lead tenant is the person in the household who does the most paid work. If several people do the same paid work, the lead tenant is whoever is the oldest."
end
end
end

9
app/models/form/lettings/questions/person_gender_identity.rb

@ -6,7 +6,6 @@ class Form::Lettings::Questions::PersonGenderIdentity < ::Form::Question
@header = "Which of these best describes person #{person_index}’s gender identity?"
@type = "radio"
@check_answers_card_number = person_index
@hint_text = ""
@answer_options = ANSWER_OPTIONS
@question_number = 32 + (4 * person_index)
end
@ -18,4 +17,12 @@ class Form::Lettings::Questions::PersonGenderIdentity < ::Form::Question
"divider" => { "value" => true },
"R" => { "value" => "Person prefers not to say" },
}.freeze
def hint_text
if form.start_year_after_2024?
"This should be however they personally choose to identify from the options below. This may or may not be the same as their biological sex or the sex they were assigned at birth."
else
""
end
end
end

9
app/models/form/sales/questions/gender_identity1.rb

@ -5,7 +5,6 @@ class Form::Sales::Questions::GenderIdentity1 < ::Form::Question
@check_answer_label = "Buyer 1’s gender identity"
@header = "Which of these best describes buyer 1’s gender identity?"
@type = "radio"
@hint_text = "Buyer 1 is the person in the household who does the most paid work. If it’s a joint purchase and the buyers do the same amount of paid work, buyer 1 is whoever is the oldest."
@answer_options = ANSWER_OPTIONS
@check_answers_card_number = 1
@question_number = 21
@ -17,4 +16,12 @@ class Form::Sales::Questions::GenderIdentity1 < ::Form::Question
"X" => { "value" => "Non-binary" },
"R" => { "value" => "Prefers not to say" },
}.freeze
def hint_text
if form.start_year_after_2024?
"This should be however they personally choose to identify from the options below. This may or may not be the same as their biological sex or the sex they were assigned at birth."
else
"Buyer 1 is the person in the household who does the most paid work. If it’s a joint purchase and the buyers do the same amount of paid work, buyer 1 is whoever is the oldest."
end
end
end

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

@ -22,4 +22,10 @@ class Form::Sales::Questions::GenderIdentity2 < ::Form::Question
"X" => { "value" => "Non-binary" },
"R" => { "value" => "Buyer prefers not to say" },
}.freeze
def hint_text
return unless form.start_year_after_2024?
"This should be however they personally choose to identify from the options below. This may or may not be the same as their biological sex or the sex they were assigned at birth."
end
end

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

@ -21,4 +21,10 @@ class Form::Sales::Questions::PersonGenderIdentity < ::Form::Question
"X" => { "value" => "Non-binary" },
"R" => { "value" => "Person prefers not to say" },
}.freeze
def hint_text
return unless form.start_year_after_2024?
"This should be however they personally choose to identify from the options below. This may or may not be the same as their biological sex or the sex they were assigned at birth."
end
end

69
spec/models/form/lettings/questions/gender_identity1_spec.rb

@ -0,0 +1,69 @@
require "rails_helper"
RSpec.describe Form::Lettings::Questions::GenderIdentity1, type: :model do
subject(:question) { described_class.new(nil, question_definition, page) }
let(:question_definition) { nil }
let(:page) { instance_double(Form::Page) }
let(:subsection) { instance_double(Form::Subsection) }
let(:form) { instance_double(Form) }
before do
allow(page).to receive(:subsection).and_return(subsection)
allow(subsection).to receive(:form).and_return(form)
end
it "has the correct id" do
expect(question.id).to eq("sex1")
end
it "has the correct header" do
expect(question.header).to eq("Which of these best describes the lead tenant’s gender identity?")
end
it "has the correct check_answer_label" do
expect(question.check_answer_label).to eq("Lead tenant’s gender identity")
end
it "has the correct check_answers_card_number" do
expect(question.check_answers_card_number).to eq(1)
end
it "has the correct type" do
expect(question.type).to eq("radio")
end
it "is not marked as derived" do
expect(question.derived?).to be false
end
it "has the correct answer_options" do
expect(question.answer_options).to eq({
"F" => { "value" => "Female" },
"M" => { "value" => "Male" },
"X" => { "value" => "Non-binary" },
"divider" => { "value" => true },
"R" => { "value" => "Tenant prefers not to say" },
})
end
context "with form year before 2024" do
before do
allow(form).to receive(:start_year_after_2024?).and_return(false)
end
it "has the correct hint" do
expect(question.hint_text).to eq("The lead tenant is the person in the household who does the most paid work. If several people do the same paid work, the lead tenant is whoever is the oldest.")
end
end
context "with form year >= 2024" do
before do
allow(form).to receive(:start_year_after_2024?).and_return(true)
end
it "has the correct hint" do
expect(question.hint_text).to eq("This should be however they personally choose to identify from the options below. This may or may not be the same as their biological sex or the sex they were assigned at birth.")
end
end
end

23
spec/models/form/lettings/questions/person_gender_identity_spec.rb

@ -6,6 +6,13 @@ RSpec.describe Form::Lettings::Questions::PersonGenderIdentity, type: :model do
let(:question_definition) { nil }
let(:page) { instance_double(Form::Page) }
let(:person_index) { 2 }
let(:subsection) { instance_double(Form::Subsection) }
let(:form) { instance_double(Form) }
before do
allow(page).to receive(:subsection).and_return(subsection)
allow(subsection).to receive(:form).and_return(form)
end
it "has correct page" do
expect(question.page).to eq(page)
@ -19,9 +26,25 @@ RSpec.describe Form::Lettings::Questions::PersonGenderIdentity, type: :model do
expect(question.derived?).to be false
end
context "with form year before 2024" do
before do
allow(form).to receive(:start_year_after_2024?).and_return(false)
end
it "has the correct hint" do
expect(question.hint_text).to eq("")
end
end
context "with form year >= 2024" do
before do
allow(form).to receive(:start_year_after_2024?).and_return(true)
end
it "has the correct hint" do
expect(question.hint_text).to eq("This should be however they personally choose to identify from the options below. This may or may not be the same as their biological sex or the sex they were assigned at birth.")
end
end
context "with person 2" do
it "has the correct id" do

31
spec/models/form/sales/questions/gender_identity1_spec.rb

@ -6,6 +6,13 @@ RSpec.describe Form::Sales::Questions::GenderIdentity1, type: :model do
let(:question_id) { nil }
let(:question_definition) { nil }
let(:page) { instance_double(Form::Page) }
let(:subsection) { instance_double(Form::Subsection) }
let(:form) { instance_double(Form) }
before do
allow(page).to receive(:subsection).and_return(subsection)
allow(subsection).to receive(:form).and_return(form)
end
it "has correct page" do
expect(question.page).to eq(page)
@ -31,10 +38,6 @@ RSpec.describe Form::Sales::Questions::GenderIdentity1, type: :model do
expect(question.derived?).to be false
end
it "has the correct hint" do
expect(question.hint_text).to eq("Buyer 1 is the person in the household who does the most paid work. If it’s a joint purchase and the buyers do the same amount of paid work, buyer 1 is whoever is the oldest.")
end
it "has the correct answer_options" do
expect(question.answer_options).to eq({
"F" => { "value" => "Female" },
@ -47,4 +50,24 @@ RSpec.describe Form::Sales::Questions::GenderIdentity1, type: :model do
it "has the correct check_answers_card_number" do
expect(question.check_answers_card_number).to eq(1)
end
context "with start year before 2024" do
before do
allow(form).to receive(:start_year_after_2024?).and_return(false)
end
it "has the correct hint" do
expect(question.hint_text).to eq("Buyer 1 is the person in the household who does the most paid work. If it’s a joint purchase and the buyers do the same amount of paid work, buyer 1 is whoever is the oldest.")
end
end
context "with start year >= 2024" do
before do
allow(form).to receive(:start_year_after_2024?).and_return(true)
end
it "has the correct hint" do
expect(question.hint_text).to eq("This should be however they personally choose to identify from the options below. This may or may not be the same as their biological sex or the sex they were assigned at birth.")
end
end
end

27
spec/models/form/sales/questions/gender_identity2_spec.rb

@ -6,6 +6,13 @@ RSpec.describe Form::Sales::Questions::GenderIdentity2, type: :model do
let(:question_id) { nil }
let(:question_definition) { nil }
let(:page) { instance_double(Form::Page) }
let(:subsection) { instance_double(Form::Subsection) }
let(:form) { instance_double(Form) }
before do
allow(page).to receive(:subsection).and_return(subsection)
allow(subsection).to receive(:form).and_return(form)
end
it "has correct page" do
expect(question.page).to eq(page)
@ -49,4 +56,24 @@ RSpec.describe Form::Sales::Questions::GenderIdentity2, type: :model do
{ "condition" => { "sex2" => "R" }, "value" => "Prefers not to say" },
])
end
context "with start year before 2024" do
before do
allow(form).to receive(:start_year_after_2024?).and_return(false)
end
it "has the correct hint" do
expect(question.hint_text).to be_nil
end
end
context "with start year >= 2024" do
before do
allow(form).to receive(:start_year_after_2024?).and_return(true)
end
it "has the correct hint" do
expect(question.hint_text).to eq("This should be however they personally choose to identify from the options below. This may or may not be the same as their biological sex or the sex they were assigned at birth.")
end
end
end

27
spec/models/form/sales/questions/person_gender_identity_spec.rb

@ -7,6 +7,13 @@ RSpec.describe Form::Sales::Questions::PersonGenderIdentity, type: :model do
let(:question_definition) { nil }
let(:page) { instance_double(Form::Page) }
let(:person_index) { 2 }
let(:subsection) { instance_double(Form::Subsection) }
let(:form) { instance_double(Form) }
before do
allow(page).to receive(:subsection).and_return(subsection)
allow(subsection).to receive(:form).and_return(form)
end
it "has correct page" do
expect(question.page).to eq(page)
@ -29,6 +36,26 @@ RSpec.describe Form::Sales::Questions::PersonGenderIdentity, type: :model do
})
end
context "when form year is before 2024" do
before do
allow(form).to receive(:start_year_after_2024?).and_return(false)
end
it "has the correct hint" do
expect(question.hint_text).to be_nil
end
end
context "when form year is >= 2024" do
before do
allow(form).to receive(:start_year_after_2024?).and_return(true)
end
it "has the correct hint" do
expect(question.hint_text).to eq("This should be however they personally choose to identify from the options below. This may or may not be the same as their biological sex or the sex they were assigned at birth.")
end
end
context "when person 2" do
let(:question_id) { "sex2" }
let(:person_index) { 2 }

Loading…
Cancel
Save