Skip to content

Commit

Permalink
Add end-of-flow behavior to race screens + fix new_single_filer_spec.rb
Browse files Browse the repository at this point in the history
  • Loading branch information
spompea-cfa committed Dec 17, 2024
1 parent bc7ff3a commit 293176a
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 6 deletions.
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
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
2 changes: 1 addition & 1 deletion app/views/questions/demographic_primary_race/edit.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<%= 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
5 changes: 1 addition & 4 deletions spec/features/web_intake/new_single_filer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -445,16 +445,13 @@ def intake_after_triage_up_to_documents(intake)
expect(page).to have_selector("h1", text: "What is your race?")
check "Asian"
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

0 comments on commit 293176a

Please sign in to comment.