diff --git a/app/models/form/lettings/questions/gender_identity1.rb b/app/models/form/lettings/questions/gender_identity1.rb index 769dc1850..f7bba8e89 100644 --- a/app/models/form/lettings/questions/gender_identity1.rb +++ b/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 diff --git a/app/models/form/lettings/questions/person_gender_identity.rb b/app/models/form/lettings/questions/person_gender_identity.rb index 1416a3414..657438071 100644 --- a/app/models/form/lettings/questions/person_gender_identity.rb +++ b/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 diff --git a/app/models/form/sales/questions/gender_identity1.rb b/app/models/form/sales/questions/gender_identity1.rb index b9b47ee0a..7ee550df1 100644 --- a/app/models/form/sales/questions/gender_identity1.rb +++ b/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 diff --git a/app/models/form/sales/questions/gender_identity2.rb b/app/models/form/sales/questions/gender_identity2.rb index 15ef9fda1..87c155acb 100644 --- a/app/models/form/sales/questions/gender_identity2.rb +++ b/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 diff --git a/app/models/form/sales/questions/person_gender_identity.rb b/app/models/form/sales/questions/person_gender_identity.rb index 94774f5ce..e2da876a4 100644 --- a/app/models/form/sales/questions/person_gender_identity.rb +++ b/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 diff --git a/spec/models/form/lettings/questions/gender_identity1_spec.rb b/spec/models/form/lettings/questions/gender_identity1_spec.rb new file mode 100644 index 000000000..596e38941 --- /dev/null +++ b/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 diff --git a/spec/models/form/lettings/questions/person_gender_identity_spec.rb b/spec/models/form/lettings/questions/person_gender_identity_spec.rb index 703ba764a..bff45a624 100644 --- a/spec/models/form/lettings/questions/person_gender_identity_spec.rb +++ b/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,8 +26,24 @@ RSpec.describe Form::Lettings::Questions::PersonGenderIdentity, type: :model do expect(question.derived?).to be false end - it "has the correct hint" do - expect(question.hint_text).to eq("") + 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 diff --git a/spec/models/form/sales/questions/gender_identity1_spec.rb b/spec/models/form/sales/questions/gender_identity1_spec.rb index 2abe952ed..e7f07577c 100644 --- a/spec/models/form/sales/questions/gender_identity1_spec.rb +++ b/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 diff --git a/spec/models/form/sales/questions/gender_identity2_spec.rb b/spec/models/form/sales/questions/gender_identity2_spec.rb index 7c405afc6..28a828155 100644 --- a/spec/models/form/sales/questions/gender_identity2_spec.rb +++ b/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 diff --git a/spec/models/form/sales/questions/person_gender_identity_spec.rb b/spec/models/form/sales/questions/person_gender_identity_spec.rb index 0ae959e82..6c0691d25 100644 --- a/spec/models/form/sales/questions/person_gender_identity_spec.rb +++ b/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 }