From 4ced7a64ed178aa3ad92e698a6357db7f0c2ff1a Mon Sep 17 00:00:00 2001 From: tofarr Date: Thu, 21 Mar 2024 14:28:37 -0600 Subject: [PATCH] Add page routing functionality to auto wait #187091623 (#4371) * No longer throwing error if a rejected return doesn't have an error * Make W2 controller return-to-review-able * NyPermanentAddress can now return to review * Spouse state id can now return to review * Primary state id can now return to review * W2 can now return to review * 1099G now supports return to review * All controllers now have return to review * Updated annotations * Add validation to NY 1099-G Payer's TIN #187222366 Co-authored-by: Jenny Heath --- .../state_file/return_to_review_concern.rb | 15 ++-- .../hub/state_file/efile_errors_controller.rb | 11 ++- .../az_primary_state_id_controller.rb | 1 + .../az_senior_dependents_controller.rb | 2 + .../az_spouse_state_id_controller.rb | 2 + .../ny_permanent_address_controller.rb | 1 + .../ny_primary_state_id_controller.rb | 1 + .../ny_spouse_state_id_controller.rb | 2 + .../questions/questions_controller.rb | 6 +- .../questions/unemployment_controller.rb | 9 +- .../state_file/questions/w2_controller.rb | 5 +- app/models/efile_error.rb | 49 ++++++++--- .../hub/state_file/efile_errors/edit.html.erb | 5 +- .../hub/state_file/efile_errors/show.html.erb | 5 ++ .../ny_permanent_address/edit.html.erb | 3 + .../ny_primary_state_id/_state_id.html.erb | 3 + .../return_status/_rejected.html.erb | 14 ++-- .../questions/unemployment/_form.html.erb | 3 + .../questions/unemployment/index.html.erb | 6 +- .../state_file/questions/w2/edit.html.erb | 3 + .../state_file/questions/w2/index.html.erb | 5 +- ...0259_add_correction_path_to_efile_error.rb | 5 ++ db/schema.rb | 5 +- .../az_prior_last_names_controller_spec.rb | 1 - .../az_senior_dependents_controller_spec.rb | 31 ++++++- .../questions/w2_controller_spec.rb | 31 +++++-- spec/factories/efile_errors.rb | 25 +++--- spec/features/state_file/edit_return_spec.rb | 2 +- spec/models/efile_error_spec.rb | 84 +++++++++++++++++++ 29 files changed, 272 insertions(+), 63 deletions(-) create mode 100644 db/migrate/20240314180259_add_correction_path_to_efile_error.rb create mode 100644 spec/models/efile_error_spec.rb diff --git a/app/controllers/concerns/state_file/return_to_review_concern.rb b/app/controllers/concerns/state_file/return_to_review_concern.rb index 0b957c643d..98a9bfe6f4 100644 --- a/app/controllers/concerns/state_file/return_to_review_concern.rb +++ b/app/controllers/concerns/state_file/return_to_review_concern.rb @@ -4,19 +4,18 @@ module ReturnToReviewConcern # to the review page rather than the usual next page in the flow extend ActiveSupport::Concern - private - def review_step - case params[:us_state] - when 'az' - StateFile::Questions::AzReviewController - when 'ny' - StateFile::Questions::NyReviewController - end + "StateFile::Questions::#{current_intake.state_code.titleize}ReviewController".constantize end + private + def next_step params[:return_to_review].nil? ? super : review_step end + + def prev_step + params[:return_to_review].nil? ? super : review_step + end end end \ No newline at end of file diff --git a/app/controllers/hub/state_file/efile_errors_controller.rb b/app/controllers/hub/state_file/efile_errors_controller.rb index 6dbbd78f80..7f1d6fd6f6 100644 --- a/app/controllers/hub/state_file/efile_errors_controller.rb +++ b/app/controllers/hub/state_file/efile_errors_controller.rb @@ -7,7 +7,14 @@ def index @efile_errors = @efile_errors.where.not(service_type: "ctc").order(:source, :code) end - def edit; end + def edit + @correction_path_options_for_select = EfileError.paths + unless @efile_error.correction_path.present? + @efile_error.correction_path = EfileError.controller_to_path( + EfileError.default_controller + ) + end + end def show; end @@ -34,7 +41,7 @@ def reprocess end def permitted_params - params.require(:efile_error).permit(:expose, :auto_cancel, :auto_wait, :description_en, :description_es, :resolution_en, :resolution_es) + params.require(:efile_error).permit(:expose, :auto_cancel, :auto_wait, :correction_path, :description_en, :description_es, :resolution_en, :resolution_es) end end end diff --git a/app/controllers/state_file/questions/az_primary_state_id_controller.rb b/app/controllers/state_file/questions/az_primary_state_id_controller.rb index ebf26ee6b8..02b41f3904 100644 --- a/app/controllers/state_file/questions/az_primary_state_id_controller.rb +++ b/app/controllers/state_file/questions/az_primary_state_id_controller.rb @@ -1,6 +1,7 @@ module StateFile module Questions class AzPrimaryStateIdController < AuthenticatedQuestionsController + include ReturnToReviewConcern end end end diff --git a/app/controllers/state_file/questions/az_senior_dependents_controller.rb b/app/controllers/state_file/questions/az_senior_dependents_controller.rb index afcda40bd0..4d9927e44a 100644 --- a/app/controllers/state_file/questions/az_senior_dependents_controller.rb +++ b/app/controllers/state_file/questions/az_senior_dependents_controller.rb @@ -1,6 +1,8 @@ module StateFile module Questions class AzSeniorDependentsController < AuthenticatedQuestionsController + include ReturnToReviewConcern + def self.show?(intake) intake.dependents.count(&:ask_senior_questions?).positive? end diff --git a/app/controllers/state_file/questions/az_spouse_state_id_controller.rb b/app/controllers/state_file/questions/az_spouse_state_id_controller.rb index 22b76ebea4..af3df625e5 100644 --- a/app/controllers/state_file/questions/az_spouse_state_id_controller.rb +++ b/app/controllers/state_file/questions/az_spouse_state_id_controller.rb @@ -1,6 +1,8 @@ module StateFile module Questions class AzSpouseStateIdController < AuthenticatedQuestionsController + include ReturnToReviewConcern + def self.show?(intake) intake.filing_status_mfj? end diff --git a/app/controllers/state_file/questions/ny_permanent_address_controller.rb b/app/controllers/state_file/questions/ny_permanent_address_controller.rb index 8dd4b9ef99..824bf54ef6 100644 --- a/app/controllers/state_file/questions/ny_permanent_address_controller.rb +++ b/app/controllers/state_file/questions/ny_permanent_address_controller.rb @@ -1,6 +1,7 @@ module StateFile module Questions class NyPermanentAddressController < AuthenticatedQuestionsController + include ReturnToReviewConcern include EligibilityOffboardingConcern end end diff --git a/app/controllers/state_file/questions/ny_primary_state_id_controller.rb b/app/controllers/state_file/questions/ny_primary_state_id_controller.rb index d9967bc338..de6b7bbe67 100644 --- a/app/controllers/state_file/questions/ny_primary_state_id_controller.rb +++ b/app/controllers/state_file/questions/ny_primary_state_id_controller.rb @@ -1,6 +1,7 @@ module StateFile module Questions class NyPrimaryStateIdController < AuthenticatedQuestionsController + include ReturnToReviewConcern end end end diff --git a/app/controllers/state_file/questions/ny_spouse_state_id_controller.rb b/app/controllers/state_file/questions/ny_spouse_state_id_controller.rb index 274ee846b5..6c89204d1f 100644 --- a/app/controllers/state_file/questions/ny_spouse_state_id_controller.rb +++ b/app/controllers/state_file/questions/ny_spouse_state_id_controller.rb @@ -1,6 +1,8 @@ module StateFile module Questions class NySpouseStateIdController < AuthenticatedQuestionsController + include ReturnToReviewConcern + def self.show?(intake) intake.filing_status_mfj? end diff --git a/app/controllers/state_file/questions/questions_controller.rb b/app/controllers/state_file/questions/questions_controller.rb index 881dc0feb4..5cce0ed62d 100644 --- a/app/controllers/state_file/questions/questions_controller.rb +++ b/app/controllers/state_file/questions/questions_controller.rb @@ -64,8 +64,12 @@ def next_path step_for_next_path.to_path_helper(options) end + def prev_step + form_navigation.prev + end + def prev_path - path_for_step(form_navigation.prev) + path_for_step(prev_step) end def path_for_step(step) diff --git a/app/controllers/state_file/questions/unemployment_controller.rb b/app/controllers/state_file/questions/unemployment_controller.rb index d2943c7a5a..41dcad5479 100644 --- a/app/controllers/state_file/questions/unemployment_controller.rb +++ b/app/controllers/state_file/questions/unemployment_controller.rb @@ -1,6 +1,7 @@ module StateFile module Questions class UnemploymentController < AuthenticatedQuestionsController + include ReturnToReviewConcern include OtherOptionsLinksConcern before_action :load_faq_link, only: [:new, :edit] @@ -34,12 +35,12 @@ def update if @state_file1099_g.had_box_11_no? @state_file1099_g.destroy - return redirect_to action: :index + return redirect_to action: :index, return_to_review: params[:return_to_review] end if @state_file1099_g.valid? @state_file1099_g.save - redirect_to action: :index + redirect_to action: :index, return_to_review: params[:return_to_review] else render :edit end @@ -53,7 +54,7 @@ def create if @state_file1099_g.valid? @state_file1099_g.save - redirect_to action: :index + redirect_to action: :index, return_to_review: params[:return_to_review] else render :new end @@ -64,7 +65,7 @@ def destroy if @state_file1099_g.destroy flash[:notice] = I18n.t("state_file.questions.unemployment.destroy.removed", name: @state_file1099_g.recipient_name) end - redirect_to action: :index + redirect_to action: :index, return_to_review: params[:return_to_review] end private diff --git a/app/controllers/state_file/questions/w2_controller.rb b/app/controllers/state_file/questions/w2_controller.rb index dcb83b6291..3309b86c14 100644 --- a/app/controllers/state_file/questions/w2_controller.rb +++ b/app/controllers/state_file/questions/w2_controller.rb @@ -1,6 +1,7 @@ module StateFile module Questions class W2Controller < AuthenticatedQuestionsController + include ReturnToReviewConcern before_action :load_w2s before_action :load_w2, only: [:edit, :update] @@ -35,7 +36,7 @@ def update if @w2.valid? @w2.save redirect_to next_path and return if @w2s.length == 1 - redirect_to action: :index + redirect_to action: :index, return_to_review: params[:return_to_review] else render :edit end @@ -76,7 +77,7 @@ def load_w2 def prev_path if @w2s.length > 1 && ["update", "edit"].include?(action_name) - return path_for_step(self.class) + return self.class.to_path_helper(action: :index, us_state: params[:us_state], return_to_review: params[:return_to_review]) end super end diff --git a/app/models/efile_error.rb b/app/models/efile_error.rb index 8568c4518e..001c025b92 100644 --- a/app/models/efile_error.rb +++ b/app/models/efile_error.rb @@ -2,18 +2,19 @@ # # Table name: efile_errors # -# id :bigint not null, primary key -# auto_cancel :boolean default(FALSE) -# auto_wait :boolean default(FALSE) -# category :string -# code :string -# expose :boolean default(FALSE) -# message :text -# service_type :integer default("unfilled"), not null -# severity :string -# source :string -# created_at :datetime not null -# updated_at :datetime not null +# id :bigint not null, primary key +# auto_cancel :boolean default(FALSE) +# auto_wait :boolean default(FALSE) +# category :string +# code :string +# correction_path :string +# expose :boolean default(FALSE) +# message :text +# service_type :integer default("unfilled"), not null +# severity :string +# source :string +# created_at :datetime not null +# updated_at :datetime not null # class EfileError < ApplicationRecord has_rich_text :description_en @@ -47,4 +48,28 @@ def resolution(locale) resolution_es.present? ? resolution_es : resolution_en end end + + def self.path_to_controller(path) + "StateFile::Questions::#{path.gsub("-", "_").camelize}Controller".constantize + end + + def self.controller_to_path(controller) + controller.name.split("::")[-1][0..-11].underscore.gsub("_", "-") + end + + def self.default_controller + StateFile::Questions::NameDobController + end + + def self.paths + paths = Set.new + StateFileBaseIntake::STATE_CODES.each do |state_code| + navigation = "Navigation::StateFile#{state_code.titleize}QuestionNavigation".constantize + navigation.controllers.each do |controller| + paths << EfileError.controller_to_path(controller) + end + end + paths.to_a.sort + end + end diff --git a/app/views/hub/state_file/efile_errors/edit.html.erb b/app/views/hub/state_file/efile_errors/edit.html.erb index ac407ba063..e1a0db285f 100644 --- a/app/views/hub/state_file/efile_errors/edit.html.erb +++ b/app/views/hub/state_file/efile_errors/edit.html.erb @@ -8,7 +8,10 @@ <%= f.hub_checkbox :expose, "Exposed to client? (exposes reject code and description on return-status page)" %> <%= f.hub_checkbox :auto_cancel, "Auto-cancel?" %> <%= f.hub_checkbox :auto_wait, "Auto-wait? (shows terminal reject state on return-status page)" %> - +
+ <%= f.label "Correction Path" %>
+ <%= f.select :correction_path, @correction_path_options_for_select, selected: @efile_error.correction_path %> +
<%= f.label :description_en, "Description [English] (overwrites default reject description on return-status page)", class: "h4" %> <%= f.rich_text_area :description_en %> diff --git a/app/views/hub/state_file/efile_errors/show.html.erb b/app/views/hub/state_file/efile_errors/show.html.erb index 891556096a..bc2c4d3147 100644 --- a/app/views/hub/state_file/efile_errors/show.html.erb +++ b/app/views/hub/state_file/efile_errors/show.html.erb @@ -19,6 +19,11 @@ <%= image_tag @efile_error.auto_wait ? "icons/check.svg" : "icons/cancelled.svg", alt: @efile_error.auto_wait ? "yes" : "no" %>
+
+

Correction Path

+ <%= @efile_error.correction_path.present? ? @efile_error.correction_path : "N/A" %> +
+

Description (English)

<%= @efile_error.description_en.present? ? @efile_error.description_en : "N/A" %> diff --git a/app/views/state_file/questions/ny_permanent_address/edit.html.erb b/app/views/state_file/questions/ny_permanent_address/edit.html.erb index a9e7c39b33..d662aa4abc 100644 --- a/app/views/state_file/questions/ny_permanent_address/edit.html.erb +++ b/app/views/state_file/questions/ny_permanent_address/edit.html.erb @@ -9,6 +9,9 @@

<%= form_with model: @form, url: { action: :update }, local: true, method: "put", builder: VitaMinFormBuilder do |f| %> + <% if params[:return_to_review].present? %> + <%= hidden_field_tag "return_to_review", params[:return_to_review] %> + <% end %>
diff --git a/app/views/state_file/questions/ny_primary_state_id/_state_id.html.erb b/app/views/state_file/questions/ny_primary_state_id/_state_id.html.erb index 40c734c987..fc58165f87 100644 --- a/app/views/state_file/questions/ny_primary_state_id/_state_id.html.erb +++ b/app/views/state_file/questions/ny_primary_state_id/_state_id.html.erb @@ -1,4 +1,7 @@ <%= form_with model: @form, url: { action: :update }, local: true, method: "put", builder: VitaMinFormBuilder do |f| %> + <% if params[:return_to_review].present? %> + <%= hidden_field_tag "return_to_review", params[:return_to_review] %> + <% end %>
diff --git a/app/views/state_file/questions/return_status/_rejected.html.erb b/app/views/state_file/questions/return_status/_rejected.html.erb index 564f5504ce..2a6ff43816 100644 --- a/app/views/state_file/questions/return_status/_rejected.html.erb +++ b/app/views/state_file/questions/return_status/_rejected.html.erb @@ -8,7 +8,7 @@ <%= t("state_file.questions.return_status.rejected.title", state_name: States.name_for_key(params[:us_state].upcase)) %> -<% if @error.expose %> +<% if @error&.expose %> <% if @error.code.present? %>
<%= t('.reject_code') %> @@ -16,7 +16,7 @@
<% end %> - <% if @error.message.present? || @error.description(I18n.locale).present? %> + <% if @error&.message.present? || @error&.description(I18n.locale).present? %>
<%= t('.reject_desc') %> <%= @error.description(I18n.locale).present? ? @error.description(I18n.locale) : @error.message %> @@ -31,7 +31,7 @@
<% end %> -<% if @error.auto_cancel %> +<% if @error&.auto_cancel %>

<%= t('.next_steps.no_edit.title') %>

<%= t('.next_steps.no_edit.body_html') %> @@ -49,6 +49,10 @@ <%= t('.contact_us') %>
- <% edit_return_path = params[:us_state] == 'az' ? az_questions_name_dob_path : ny_questions_name_dob_path %> - <%= link_to t('.edit_return'), edit_return_path, class: "button button--primary spacing-above-60" %> + <% edit_return_controller = @error.correction_path.present? ? EfileError.path_to_controller(@error.correction_path) : EfileError.default_controller %> + <%= link_to t('.edit_return'), edit_return_controller.to_path_helper( + action: edit_return_controller.navigation_actions.first, + return_to_review: :y, + us_state: current_intake.state_code + ), class: "button button--primary spacing-above-60" %> <% end %> diff --git a/app/views/state_file/questions/unemployment/_form.html.erb b/app/views/state_file/questions/unemployment/_form.html.erb index 43709e2fa2..34c9e10997 100644 --- a/app/views/state_file/questions/unemployment/_form.html.erb +++ b/app/views/state_file/questions/unemployment/_form.html.erb @@ -6,6 +6,9 @@ <% content_for :card do %>

<%= @main_heading %>

<%= form_with model: @state_file1099_g, url: { action: @state_file1099_g.persisted? ? :update : :create }, local: true, builder: VitaMinFormBuilder, html: { class: 'form-card form-card--long' } do |f| %> + <% if params[:return_to_review].present? %> + <%= hidden_field_tag "return_to_review", params[:return_to_review] %> + <% end %>
diff --git a/app/views/state_file/questions/unemployment/index.html.erb b/app/views/state_file/questions/unemployment/index.html.erb index e1216a5618..b67128087d 100644 --- a/app/views/state_file/questions/unemployment/index.html.erb +++ b/app/views/state_file/questions/unemployment/index.html.erb @@ -15,8 +15,8 @@ <%= t('.unemployment_compensation', amount: form1099.unemployment_compensation) %>

- <%= link_to t("general.edit"), StateFile::Questions::UnemploymentController.to_path_helper(us_state: params[:us_state], id: form1099), class: "button--small button--inline-action" %> - <%= link_to t("general.delete"), StateFile::Questions::UnemploymentController.to_path_helper(action: :destroy, us_state: params[:us_state], id: form1099), method: :delete, data: {confirm: t(".delete_confirmation")}, class: "button--small button--inline-action last" %> + <%= link_to t("general.edit"), StateFile::Questions::UnemploymentController.to_path_helper(us_state: params[:us_state], id: form1099, return_to_review: params[:return_to_review]), class: "button--small button--inline-action" %> + <%= link_to t("general.delete"), StateFile::Questions::UnemploymentController.to_path_helper(action: :destroy, us_state: params[:us_state], id: form1099, return_to_review: params[:return_to_review]), method: :delete, data: {confirm: t(".delete_confirmation")}, class: "button--small button--inline-action last" %>
@@ -26,7 +26,7 @@ <%= link_to(next_path, class: "button button--primary button--wide spacing-below-10") do %> <%= t('general.continue') %> <% end %> - <%= link_to(StateFile::Questions::UnemploymentController.to_path_helper(action: :new, us_state: params[:us_state]), class: "button button--wide") do %> + <%= link_to(StateFile::Questions::UnemploymentController.to_path_helper(action: :new, us_state: params[:us_state], return_to_review: params[:return_to_review]), class: "button button--wide") do %> <%= t('.add_another') %> <% end %> <% end %> diff --git a/app/views/state_file/questions/w2/edit.html.erb b/app/views/state_file/questions/w2/edit.html.erb index 3265236d87..f2770acc1e 100644 --- a/app/views/state_file/questions/w2/edit.html.erb +++ b/app/views/state_file/questions/w2/edit.html.erb @@ -2,6 +2,9 @@

<%= t(".instructions_1", employer_name: @employer_name , total_wages_amt: number_to_currency(@wages_amt)) %>

<%= t(".instructions_2") %>

<%= form_with model: @w2, url: { action: :update }, method: :patch, local: true, builder: VitaMinFormBuilder, html: { class: 'form-card form-card--long' } do |f| %> + <% if params[:return_to_review].present? %> + <%= hidden_field_tag "return_to_review", params[:return_to_review] %> + <% end %>
<%=t("general.state") %>
diff --git a/app/views/state_file/questions/w2/index.html.erb b/app/views/state_file/questions/w2/index.html.erb index 35893c511d..7dc21f2d25 100644 --- a/app/views/state_file/questions/w2/index.html.erb +++ b/app/views/state_file/questions/w2/index.html.erb @@ -20,12 +20,15 @@
- <%= link_to t("general.update"), StateFile::Questions::W2Controller.to_path_helper(us_state: params[:us_state], action: :edit, id: w2.w2_index), class: "button--small button--inline-action" %> + <%= link_to t("general.update"), StateFile::Questions::W2Controller.to_path_helper(us_state: params[:us_state], action: :edit, id: w2.w2_index, return_to_review: params[:return_to_review]), class: "button--small button--inline-action" %>
<% end %> <%= form_with model: @w2, url: { action: :create }, method: :post, local: true, builder: VitaMinFormBuilder, html: { class: 'form-card form-card--long' } do |f| %> + <% if params[:return_to_review].present? %> + <%= hidden_field_tag "return_to_review", params[:return_to_review] %> + <% end %> <%= f.continue %> <% if @errors_present %> diff --git a/db/migrate/20240314180259_add_correction_path_to_efile_error.rb b/db/migrate/20240314180259_add_correction_path_to_efile_error.rb new file mode 100644 index 0000000000..c8100aeeb0 --- /dev/null +++ b/db/migrate/20240314180259_add_correction_path_to_efile_error.rb @@ -0,0 +1,5 @@ +class AddCorrectionPathToEfileError < ActiveRecord::Migration[7.1] + def change + add_column :efile_errors, :correction_path, :string + end +end diff --git a/db/schema.rb b/db/schema.rb index 6d86bb3a0d..4ac32ee895 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,9 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[7.1].define(version: 2024_03_07_232948) do +ActiveRecord::Schema[7.1].define(version: 2024_03_14_180259) do + create_schema "analytics" + # These are extensions that must be enabled in order to support this database enable_extension "citext" enable_extension "plpgsql" @@ -791,6 +793,7 @@ t.boolean "auto_wait", default: false t.string "category" t.string "code" + t.string "correction_path" t.datetime "created_at", null: false t.boolean "expose", default: false t.text "message" diff --git a/spec/controllers/state_file/questions/az_prior_last_names_controller_spec.rb b/spec/controllers/state_file/questions/az_prior_last_names_controller_spec.rb index 0c5dc0597e..0ccef2f2ae 100644 --- a/spec/controllers/state_file/questions/az_prior_last_names_controller_spec.rb +++ b/spec/controllers/state_file/questions/az_prior_last_names_controller_spec.rb @@ -34,7 +34,6 @@ end end - context "without device id information due to JS being disabled" do let(:device_id) { nil } diff --git a/spec/controllers/state_file/questions/az_senior_dependents_controller_spec.rb b/spec/controllers/state_file/questions/az_senior_dependents_controller_spec.rb index 6d0e93eb0f..d230550df3 100644 --- a/spec/controllers/state_file/questions/az_senior_dependents_controller_spec.rb +++ b/spec/controllers/state_file/questions/az_senior_dependents_controller_spec.rb @@ -1,21 +1,44 @@ require 'rails_helper' RSpec.describe StateFile::Questions::AzSeniorDependentsController do + + let(:dependent_name) { :az_senior_dependent } + let(:dependent) { create(dependent_name) } + let(:intake) { create(:state_file_az_intake, dependents: [dependent]) } + before { sign_in intake } + describe ".show?" do context "with any senior dependents" do it "returns true" do - intake = create(:state_file_az_intake, dependents: [create(:az_senior_dependent)]) - sign_in intake expect(described_class.show?(intake)).to eq true end end context "without senior dependents" do + let(:dependent_name) { :state_file_dependent } it "returns false" do - intake = create(:state_file_az_intake, dependents: [create(:state_file_dependent)]) - sign_in intake expect(described_class.show?(intake)).to eq false end end + + context "with the return to review parameter" do + it "returns to review" do + params = { + state_file_az_senior_dependents_form: { + dependents_attributes: { + "0": { + id: dependent.id, + needed_assistance: "yes", + passed_away: "no" + } + } + }, + return_to_review: :y, + us_state: :az + } + post :update, params: params + expect(response).to redirect_to "/en/az/questions/az-review" + end + end end end diff --git a/spec/controllers/state_file/questions/w2_controller_spec.rb b/spec/controllers/state_file/questions/w2_controller_spec.rb index f18bb6e049..192701bc16 100644 --- a/spec/controllers/state_file/questions/w2_controller_spec.rb +++ b/spec/controllers/state_file/questions/w2_controller_spec.rb @@ -82,7 +82,6 @@ expect(response).to redirect_to "/en/ny/questions/w2/0/edit" end end - end describe "#update" do @@ -98,7 +97,7 @@ context "with valid params" do let(:params) do { - us_state: :ny, + us_state: "ny", id: 1, state_file_w2: { employer_state_id_num: "12345", @@ -111,6 +110,24 @@ } end + context "when the client got here from the review flow" do + let!(:w2) { create :state_file_w2, state_file_intake: intake, w2_index: 1 } + let!(:other_w2) { create :state_file_w2, state_file_intake: intake, w2_index: 0, state_wages_amt: 8000 } + + # can't use shared example here because it's written for the default update in QuestionsController + it "keeps the redirect parameter" do + post :update, params: params.merge(return_to_review: "y") + + expect(response).to redirect_to(StateFile::Questions::W2Controller.to_path_helper(us_state: :ny, action: :index, return_to_review: :y)) + end + + it "redirects to the review page" do + post :create, params: params.merge(return_to_review: "y") + + expect(response).to redirect_to(StateFile::Questions::NyReviewController.to_path_helper(us_state: :ny, action: :edit)) + end + end + context "with existing w2" do let!(:w2) { create :state_file_w2, state_file_intake: intake, w2_index: 1 } let!(:other_w2) { create :state_file_w2, state_file_intake: intake, w2_index: 0, state_wages_amt: 8000 } @@ -193,21 +210,25 @@ end context "with a single invalid w2" do - let(:direct_file_xml) do xml = super() xml.at("IRSW2").remove xml end - let(:params) do super().merge({id: 0}) end - it "redirects to the edit page" do + it "redirects to the next page in the flow" do post :update, params: params expect(response).to redirect_to "/en/ny/questions/ny-sales-use-tax" end + + context "when the client got here from the review flow" do + it_behaves_like :return_to_review_concern do + let(:form_params) { params } + end + end end end diff --git a/spec/factories/efile_errors.rb b/spec/factories/efile_errors.rb index 8edfbf78b1..3e98c25f4a 100644 --- a/spec/factories/efile_errors.rb +++ b/spec/factories/efile_errors.rb @@ -2,18 +2,19 @@ # # Table name: efile_errors # -# id :bigint not null, primary key -# auto_cancel :boolean default(FALSE) -# auto_wait :boolean default(FALSE) -# category :string -# code :string -# expose :boolean default(FALSE) -# message :text -# service_type :integer default("unfilled"), not null -# severity :string -# source :string -# created_at :datetime not null -# updated_at :datetime not null +# id :bigint not null, primary key +# auto_cancel :boolean default(FALSE) +# auto_wait :boolean default(FALSE) +# category :string +# code :string +# correction_path :string +# expose :boolean default(FALSE) +# message :text +# service_type :integer default("unfilled"), not null +# severity :string +# source :string +# created_at :datetime not null +# updated_at :datetime not null # FactoryBot.define do factory :efile_error do diff --git a/spec/features/state_file/edit_return_spec.rb b/spec/features/state_file/edit_return_spec.rb index c2baaad9c3..651ad44844 100644 --- a/spec/features/state_file/edit_return_spec.rb +++ b/spec/features/state_file/edit_return_spec.rb @@ -96,6 +96,6 @@ select_cfa_date "state_file_name_dob_form_primary_birth_date", Date.new(1978, 6, 21) click_on I18n.t("general.continue") - expect(page).to have_text I18n.t("state_file.questions.nyc_residency.edit.title", year: 2023) + expect(URI.parse(current_url).path).to eq "/en/ny/questions/ny-review" end end \ No newline at end of file diff --git a/spec/models/efile_error_spec.rb b/spec/models/efile_error_spec.rb new file mode 100644 index 0000000000..9c5a8ef7bd --- /dev/null +++ b/spec/models/efile_error_spec.rb @@ -0,0 +1,84 @@ +# == Schema Information +# +# Table name: efile_errors +# +# id :bigint not null, primary key +# auto_cancel :boolean default(FALSE) +# auto_wait :boolean default(FALSE) +# category :string +# code :string +# correction_path :string +# expose :boolean default(FALSE) +# message :text +# service_type :integer default("unfilled"), not null +# severity :string +# source :string +# created_at :datetime not null +# updated_at :datetime not null +# +require 'rails_helper' + +describe 'EfileError' do + it 'returns name dob as the default controller' do + expect(EfileError.default_controller).to eq StateFile::Questions::NameDobController + end + + it 'converts controllers to paths' do + path = EfileError.controller_to_path(StateFile::Questions::NameDobController) + expect(path).to eq "name-dob" + end + + it 'converts paths to controllers' do + controller = EfileError.path_to_controller("w2") + expect(controller).to eq StateFile::Questions::W2Controller + end + + it 'returns the expected array of paths' do + expect(EfileError.paths).to eq [ + "az-charitable-contributions", + "az-excise-credit", + "az-primary-state-id", + "az-prior-last-names", + "az-review", + "az-senior-dependents", + "az-spouse-state-id", + "az-state-credits", + "canceled-data-transfer", + "code-verified", + "contact-preference", + "data-review", + "data-transfer-offboarding", + "declined-terms-and-conditions", + "eligibility-offboarding", + "eligibility-out-of-state-income", + "eligibility-residence", + "eligible", + "email-address", + "esign-declaration", + "federal-info", + "initiate-data-transfer", + "landing-page", + "name-dob", + "ny-county", + "ny-eligibility-college-savings-withdrawal", + "ny-permanent-address", + "ny-primary-state-id", + "ny-review", + "ny-sales-use-tax", + "ny-school-district", + "ny-spouse-state-id", + "ny-third-party-designee", + "nyc-residency", + "phone-number", + "return-status", + "submission-confirmation", + "tax-refund", + "taxes-owed", + "terms-and-conditions", + "unemployment", + "verification-code", + "w2", + "waiting-to-load-data" + ] + end +end