Skip to content

Commit

Permalink
GYR1-609 Combine race ethnicity questions and add mena as demographic…
Browse files Browse the repository at this point in the history
… option (#5210)

- Removed ethnicity screens (primary and spouse) from flow; note that the race 
  screens are now effectively the new combined race/ethnicity screens.
- Since those had been the last screens in the flow, copied over the logic from 
  the ethnicity controllers into the race controllers (also changed a view).
- Added demographic_primary_mena and demographic_spouse_mena booleans to intakes 
  table.
- Added MENA choice to race screens.
- Added Hispanic or Latino choice to race screens (previously was asked on 
  separate ethnicity screen).
- Tweaked spec tests to accommodate.
  • Loading branch information
spompea-cfa authored Jan 22, 2025
1 parent 81cac2e commit 1adcf0f
Show file tree
Hide file tree
Showing 24 changed files with 123 additions and 42 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@ class DemographicPrimaryEthnicityController < PostCompletionQuestionsController

layout "intake"

def self.show?(intake)
intake.demographic_questions_opt_in_yes?
end
def self.show?(intake) = false

def illustration_path; end

Expand Down
18 changes: 18 additions & 0 deletions app/controllers/questions/demographic_primary_race_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,23 @@ def self.show?(intake)
end

def illustration_path; end

def next_path
default_next_path = super
if default_next_path.nil?
root_path
else
default_next_path
end
end

private

def after_update_success
super
if next_path == root_path
clear_intake_session
end
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,7 @@ class DemographicSpouseEthnicityController < PostCompletionQuestionsController

layout "intake"

def self.show?(intake)
if intake == nil
return false
end
intake.demographic_questions_opt_in_yes? && intake.filing_joint_yes?
end
def self.show?(intake) = false

def illustration_path; end

Expand Down
15 changes: 14 additions & 1 deletion app/controllers/questions/demographic_spouse_race_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,22 @@ class DemographicSpouseRaceController < PostCompletionQuestionsController
layout "intake"

def self.show?(intake)
intake.demographic_questions_opt_in_yes? && intake.filing_joint_yes?
intake&.demographic_questions_opt_in_yes? && intake&.filing_joint_yes?
end

def illustration_path; end

private

def next_path
root_path
end

def after_update_success
super
if next_path == root_path
clear_intake_session
end
end
end
end
4 changes: 3 additions & 1 deletion app/forms/demographic_primary_race_form.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ class DemographicPrimaryRaceForm < QuestionsForm
set_attributes_for :intake,
:demographic_primary_american_indian_alaska_native,
:demographic_primary_black_african_american,
:demographic_primary_mena,
:demographic_primary_hispanic_latino,
:demographic_primary_native_hawaiian_pacific_islander,
:demographic_primary_asian,
:demographic_primary_white,
Expand All @@ -17,4 +19,4 @@ def save
end
@intake.update(attributes)
end
end
end
4 changes: 3 additions & 1 deletion app/forms/demographic_spouse_race_form.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ class DemographicSpouseRaceForm < QuestionsForm
set_attributes_for :intake,
:demographic_spouse_american_indian_alaska_native,
:demographic_spouse_black_african_american,
:demographic_spouse_mena,
:demographic_spouse_hispanic_latino,
:demographic_spouse_native_hawaiian_pacific_islander,
:demographic_spouse_asian,
:demographic_spouse_white,
Expand All @@ -16,4 +18,4 @@ def save
end
@intake.update(attributes)
end
end
end
2 changes: 0 additions & 2 deletions app/lib/navigation/gyr_question_navigation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,6 @@ class GyrQuestionNavigation
Questions::DemographicVeteranController,
Questions::DemographicPrimaryRaceController,
Questions::DemographicSpouseRaceController,
Questions::DemographicPrimaryEthnicityController,
Questions::DemographicSpouseEthnicityController,
].freeze
end
end
4 changes: 4 additions & 0 deletions app/models/intake.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@
# demographic_primary_asian :boolean
# demographic_primary_black_african_american :boolean
# demographic_primary_ethnicity :integer default(0), not null
# demographic_primary_hispanic_latino :boolean
# demographic_primary_mena :boolean
# demographic_primary_native_hawaiian_pacific_islander :boolean
# demographic_primary_prefer_not_to_answer_race :boolean
# demographic_primary_white :boolean
Expand All @@ -48,6 +50,8 @@
# demographic_spouse_asian :boolean
# demographic_spouse_black_african_american :boolean
# demographic_spouse_ethnicity :integer default(0), not null
# demographic_spouse_hispanic_latino :boolean
# demographic_spouse_mena :boolean
# demographic_spouse_native_hawaiian_pacific_islander :boolean
# demographic_spouse_prefer_not_to_answer_race :boolean
# demographic_spouse_white :boolean
Expand Down
4 changes: 4 additions & 0 deletions app/models/intake/ctc_intake.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@
# demographic_primary_asian :boolean
# demographic_primary_black_african_american :boolean
# demographic_primary_ethnicity :integer default(0), not null
# demographic_primary_hispanic_latino :boolean
# demographic_primary_mena :boolean
# demographic_primary_native_hawaiian_pacific_islander :boolean
# demographic_primary_prefer_not_to_answer_race :boolean
# demographic_primary_white :boolean
Expand All @@ -48,6 +50,8 @@
# demographic_spouse_asian :boolean
# demographic_spouse_black_african_american :boolean
# demographic_spouse_ethnicity :integer default(0), not null
# demographic_spouse_hispanic_latino :boolean
# demographic_spouse_mena :boolean
# demographic_spouse_native_hawaiian_pacific_islander :boolean
# demographic_spouse_prefer_not_to_answer_race :boolean
# demographic_spouse_white :boolean
Expand Down
4 changes: 4 additions & 0 deletions app/models/intake/gyr_intake.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@
# demographic_primary_asian :boolean
# demographic_primary_black_african_american :boolean
# demographic_primary_ethnicity :integer default("unfilled"), not null
# demographic_primary_hispanic_latino :boolean
# demographic_primary_mena :boolean
# demographic_primary_native_hawaiian_pacific_islander :boolean
# demographic_primary_prefer_not_to_answer_race :boolean
# demographic_primary_white :boolean
Expand All @@ -48,6 +50,8 @@
# demographic_spouse_asian :boolean
# demographic_spouse_black_african_american :boolean
# demographic_spouse_ethnicity :integer default("unfilled"), not null
# demographic_spouse_hispanic_latino :boolean
# demographic_spouse_mena :boolean
# demographic_spouse_native_hawaiian_pacific_islander :boolean
# demographic_spouse_prefer_not_to_answer_race :boolean
# demographic_spouse_white :boolean
Expand Down
4 changes: 3 additions & 1 deletion app/views/questions/demographic_primary_race/edit.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@
<%= f.cfa_checkbox(:demographic_primary_native_hawaiian_pacific_islander, t("general.race.native_hawaiian_pacific_islander"), options: { checked_value: true, unchecked_value: false }) %>
<%= f.cfa_checkbox(:demographic_primary_asian, t("general.race.asian"), options: { checked_value: true, unchecked_value: false }) %>
<%= f.cfa_checkbox(:demographic_primary_black_african_american, t("general.race.black_african_american"), options: { checked_value: true, unchecked_value: false }) %>
<%= f.cfa_checkbox(:demographic_primary_hispanic_latino, t("general.race.hispanic_latino"), options: { checked_value: true, unchecked_value: false }) %>
<%= f.cfa_checkbox(:demographic_primary_mena, t("general.race.mena"), options: { checked_value: true, unchecked_value: false }) %>
<%= f.cfa_checkbox(:demographic_primary_white, t("general.race.white"), options: { checked_value: true, unchecked_value: false }) %>
</div>

<%= f.continue %>
<%= f.continue Questions::DemographicSpouseRaceController.show?(current_intake) ? t("general.continue") : t("general.submit") %>
<%= f.button :submit, name: "#{f.object_name}[demographic_primary_prefer_not_to_answer_race]", value: true, class: "button button--wide", "aria-describedby": "demographic_primary_race_question" do %>
<%=t("general.skip_question") %>
<% end %>
Expand Down
2 changes: 2 additions & 0 deletions app/views/questions/demographic_spouse_race/edit.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
<%= f.cfa_checkbox(:demographic_spouse_native_hawaiian_pacific_islander, t("general.race.native_hawaiian_pacific_islander"), options: { checked_value: true, unchecked_value: false }) %>
<%= f.cfa_checkbox(:demographic_spouse_asian, t("general.race.asian"), options: { checked_value: true, unchecked_value: false }) %>
<%= f.cfa_checkbox(:demographic_spouse_black_african_american, t("general.race.black_african_american"), options: { checked_value: true, unchecked_value: false }) %>
<%= f.cfa_checkbox(:demographic_spouse_hispanic_latino, t("general.race.hispanic_latino"), options: { checked_value: true, unchecked_value: false }) %>
<%= f.cfa_checkbox(:demographic_spouse_mena, t("general.race.mena"), options: { checked_value: true, unchecked_value: false }) %>
<%= f.cfa_checkbox(:demographic_spouse_white, t("general.race.white"), options: { checked_value: true, unchecked_value: false }) %>
</div>

Expand Down
6 changes: 4 additions & 2 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -538,6 +538,8 @@ en:
american_indian_alaska_native: American Indian or Alaska Native
asian: Asian
black_african_american: Black or African American
hispanic_latino: Hispanic or Latino
mena: Middle Eastern or North African
native_hawaiian_pacific_islander: Native Hawaiian or other Pacific Islander
white: White
register: Sign Up
Expand Down Expand Up @@ -6029,13 +6031,13 @@ en:
demographic_primary_ethnicity:
title: What is your ethnicity?
demographic_primary_race:
title: What is your race?
title: What is your race and/or ethnicity?
demographic_questions:
title: Are you willing to answer some additional questions to help us better serve you?
demographic_spouse_ethnicity:
title: What is your spouse's ethnicity?
demographic_spouse_race:
title: What is your spouse's race?
title: What is your spouse's race and/or ethnicity?
demographic_veteran:
title: Are you or your spouse a veteran of the U.S. Armed Forces?
dependent_care:
Expand Down
6 changes: 4 additions & 2 deletions config/locales/es.yml
Original file line number Diff line number Diff line change
Expand Up @@ -540,6 +540,8 @@ es:
american_indian_alaska_native: Indio Americano o Nativo de Alaska
asian: Asiático
black_african_american: Negro o afroamericano
hispanic_latino: Hispano o latino
mena: Oriente Medio o norteafricano
native_hawaiian_pacific_islander: Nativo de Hawái u otra isla del Pacífico
white: Blanco
register: Regístrate
Expand Down Expand Up @@ -6027,13 +6029,13 @@ es:
demographic_primary_ethnicity:
title: Cuál es tu etnicidad?
demographic_primary_race:
title: "¿Cuál es su raza?"
title: "¿Cuál es su raza y/o grupo étnico?"
demographic_questions:
title: "¿Está dispuesto a responder algunas preguntas adicionales para ayudarnos a servirle mejor?"
demographic_spouse_ethnicity:
title: "¿Cuál es el origen étnico de su cónyuge?"
demographic_spouse_race:
title: "¿Cuál es la raza de tu cónyuge?"
title: "¿Cuál es la raza y/o grupo étnico de tu cónyuge?"
demographic_veteran:
title: "¿Es usted o su cónyuge veterano de las Fuerzas Armadas de los EE. UU.?"
dependent_care:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class AddDemographicPrimaryMenaToIntakes < ActiveRecord::Migration[7.1]
def change
add_column :intakes, :demographic_primary_mena, :boolean
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class AddDemographicSpouseMenaToIntakes < ActiveRecord::Migration[7.1]
def change
add_column :intakes, :demographic_spouse_mena, :boolean
end
end
6 changes: 6 additions & 0 deletions db/migrate/20250119200253_add_hispanic_booleans_to_intakes.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
class AddHispanicBooleansToIntakes < ActiveRecord::Migration[7.1]
def change
add_column :intakes, :demographic_primary_hispanic_latino, :boolean
add_column :intakes, :demographic_spouse_hispanic_latino, :boolean
end
end
7 changes: 5 additions & 2 deletions db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema[7.1].define(version: 2025_01_16_220546) do
create_schema "analytics"
ActiveRecord::Schema[7.1].define(version: 2025_01_19_200253) do

# These are extensions that must be enabled in order to support this database
enable_extension "citext"
Expand Down Expand Up @@ -1180,6 +1179,8 @@
t.boolean "demographic_primary_asian"
t.boolean "demographic_primary_black_african_american"
t.integer "demographic_primary_ethnicity", default: 0, null: false
t.boolean "demographic_primary_hispanic_latino"
t.boolean "demographic_primary_mena"
t.boolean "demographic_primary_native_hawaiian_pacific_islander"
t.boolean "demographic_primary_prefer_not_to_answer_race"
t.boolean "demographic_primary_white"
Expand All @@ -1189,6 +1190,8 @@
t.boolean "demographic_spouse_asian"
t.boolean "demographic_spouse_black_african_american"
t.integer "demographic_spouse_ethnicity", default: 0, null: false
t.boolean "demographic_spouse_hispanic_latino"
t.boolean "demographic_spouse_mena"
t.boolean "demographic_spouse_native_hawaiian_pacific_islander"
t.boolean "demographic_spouse_prefer_not_to_answer_race"
t.boolean "demographic_spouse_white"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
require "rails_helper"

RSpec.describe Questions::DemographicPrimaryEthnicityController do
describe "#update" do
# Skip for TY2024 - we've hidden this screen from the flow.
xdescribe "#update" do
context "with valid params" do
let(:params) do
{
Expand Down Expand Up @@ -37,7 +38,8 @@
end
end

describe 'next_path' do
# Skip for TY2024 - we've hidden this screen from the flow.
xdescribe 'next_path' do
let(:intake) { create :intake, demographic_questions_opt_in: "yes", filing_joint: filing_joint }

before { sign_in intake.client }
Expand All @@ -56,4 +58,4 @@
end
end
end
end
end
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
require "rails_helper"

RSpec.describe Questions::DemographicSpouseEthnicityController do
describe "#update" do
# Skip for TY2024 - we've hidden this screen from the flow.
xdescribe "#update" do
context "with valid params" do
let(:params) do
{
Expand Down
27 changes: 15 additions & 12 deletions spec/features/web_intake/new_joint_filers_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -574,25 +574,28 @@ def intake_up_to_documents
end
click_on "Continue"
screenshot_after do
expect(page).to have_selector("h1", text: "What is your race?")
expect(page).to have_selector("h1", text: "What is your race and/or ethnicity?")
check "American Indian or Alaska Native"
check "Native Hawaiian or other Pacific Islander"
check "Asian"
check "Black or African American"
check "Hispanic or Latino"
check "Middle Eastern or North African"
check "White"

end
click_on "Continue"
screenshot_after do
expect(page).to have_selector("h1", text: "What is your spouse's race?")
expect(page).to have_selector("h1", text: "What is your spouse's race and/or ethnicity?")
check "American Indian or Alaska Native"
check "Native Hawaiian or other Pacific Islander"
check "Asian"
check "Black or African American"
check "Hispanic or Latino"
check "Middle Eastern or North African"
check "White"
end
click_on "Continue"
screenshot_after do
expect(page).to have_text("What is your ethnicity?")
choose "Not Hispanic or Latino"
end
click_on "Continue"
screenshot_after do
expect(page).to have_text("What is your spouse's ethnicity?")
choose "Not Hispanic or Latino"
end
click_on "Continue"
end

context "client is included in the expanded id experiment", js: true do
Expand Down
12 changes: 7 additions & 5 deletions spec/features/web_intake/new_single_filer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -440,19 +440,21 @@ def intake_after_triage_up_to_documents(intake)
choose "Yes"
click_on "Continue"
expect(intake.reload.current_step).to end_with("/questions/demographic-primary-race")
expect(page).to have_selector("h1", text: "What is your race?")
expect(page).to have_selector("h1", text: "What is your race and/or ethnicity?")
check "American Indian or Alaska Native"
check "Native Hawaiian or other Pacific Islander"
check "Asian"
check "Black or African American"
check "Hispanic or Latino"
check "Middle Eastern or North African"
check "White"
click_on "Continue"
expect(page).to have_text("What is your ethnicity?")
choose "Not Hispanic or Latino"
click_on "Submit"

expect(page).to have_selector("h1", text: "Free tax filing")

# going back to another page after submit redirects to client login, does not reset current_step
visit "/questions/work-situations"
expect(intake.reload.current_step).to end_with("/questions/demographic-primary-ethnicity")
expect(intake.reload.current_step).to end_with("/questions/demographic-primary-race")
expect(page).to have_selector("h1", text: I18n.t("portal.client_logins.new.title"))
end
end
Expand Down
Loading

0 comments on commit 1adcf0f

Please sign in to comment.