|
1 | 1 | require "rails_helper" |
2 | 2 |
|
3 | 3 | RSpec.describe StateFile::Questions::ReturnStatusController do |
4 | | - describe "#edit" do |
5 | | - context "assignment of various instance variables" do |
6 | | - it "assigns them correctly" do |
7 | | - az_intake = create(:state_file_az_intake) |
8 | | - sign_in az_intake |
9 | | - create(:efile_submission, :notified_of_rejection, :for_state, data_source: az_intake) |
10 | | - get :edit |
11 | | - |
12 | | - expect(assigns(:tax_refund_url)).to eq "https://aztaxes.gov/home/checkrefund" |
13 | | - expect(assigns(:tax_payment_url)).to eq "AZTaxes.gov" |
14 | | - expect(assigns(:voucher_form_name)).to eq "Form AZ-140V" |
15 | | - expect(assigns(:mail_voucher_address)).to eq "Arizona Department of Revenue<br/>"\ |
16 | | - "PO Box 29085<br/>"\ |
17 | | - "Phoenix, AZ 85038-9085" |
18 | | - expect(assigns(:voucher_path)).to eq "/pdfs/AZ-140V.pdf" |
19 | | - expect(assigns(:survey_link)).to eq "https://codeforamerica.co1.qualtrics.com/jfe/form/SV_7UTycCvS3UEokey" |
20 | | - end |
21 | | - end |
22 | | - |
23 | | - context "AZ" do |
24 | | - render_views |
25 | | - let(:az_intake) { create :state_file_az_intake } |
26 | | - before do |
27 | | - sign_in az_intake |
28 | | - end |
29 | | - |
30 | | - context "happy path" do |
31 | | - let!(:efile_submission) { create(:efile_submission, :notified_of_rejection, :for_state, data_source: az_intake) } |
32 | | - |
33 | | - it "shows the most recent submission" do |
34 | | - get :edit |
35 | | - |
36 | | - expect(assigns(:submission_to_show)).to eq efile_submission |
37 | | - end |
38 | | - end |
39 | | - |
40 | | - context "unhappy path" do |
41 | | - let!(:previous_efile_submission) { create(:efile_submission, :accepted, :for_state, data_source: az_intake) } |
42 | | - let!(:latest_efile_submission) { create(:efile_submission, :transmitted, :for_state, data_source: az_intake) } |
| 4 | + StateFile::StateInformationService.active_state_codes.each do |state_code| |
| 5 | + context "#{state_code}" do |
| 6 | + describe "#edit" do |
| 7 | + render_views |
| 8 | + let(:intake) { create(StateFile::StateInformationService.intake_class(state_code).name.underscore.to_sym) } |
43 | 9 |
|
44 | 10 | before do |
45 | | - latest_efile_submission.transition_to!(:rejected) |
46 | | - create(:efile_submission_transition_error, efile_error: efile_error, efile_submission_transition: latest_efile_submission.last_transition, efile_submission_id: latest_efile_submission.id) |
47 | | - latest_efile_submission.transition_to!(:cancelled) |
| 11 | + sign_in intake |
48 | 12 | end |
49 | 13 |
|
50 | | - context "client got accepted and then submitted another return which got reject 901" do |
51 | | - let(:efile_error) { create(:efile_error, code: "901", service_type: :state_file_az, expose: true) } |
52 | | - |
53 | | - it "shows the most recent accepted submission" do |
| 14 | + context "assignment of various instance variables" do |
| 15 | + it "assigns the ones from the config service correctly" do |
| 16 | + create(:efile_submission, :notified_of_rejection, :for_state, data_source: intake) |
54 | 17 | get :edit |
55 | 18 |
|
56 | | - expect(assigns(:submission_to_show)).to eq previous_efile_submission |
| 19 | + expect(assigns(:tax_refund_url)).to eq StateFile::StateInformationService.tax_refund_url(state_code) |
| 20 | + expect(assigns(:tax_payment_url)).to eq StateFile::StateInformationService.tax_payment_url(state_code) |
| 21 | + expect(assigns(:voucher_form_name)).to eq StateFile::StateInformationService.voucher_form_name(state_code) |
| 22 | + expect(assigns(:mail_voucher_address)).to eq StateFile::StateInformationService.mail_voucher_address(state_code) |
| 23 | + expect(assigns(:voucher_path)).to eq StateFile::StateInformationService.voucher_path(state_code) |
| 24 | + expect(assigns(:survey_link)).to eq StateFile::StateInformationService.survey_link(state_code) |
57 | 25 | end |
58 | | - end |
59 | 26 |
|
60 | | - context "client got accepted and then submitted another return which got a different rejection" do |
61 | | - let(:efile_error) { create(:efile_error, code: "A LEGIT REJECTION I GUESS", service_type: :state_file_az, expose: true) } |
| 27 | + context "submission" do |
| 28 | + let!(:efile_submission_first) { create(:efile_submission, :notified_of_rejection, :for_state, data_source: intake) } |
| 29 | + let!(:efile_submission_last) { create(:efile_submission, :notified_of_rejection, :for_state, data_source: intake) } |
62 | 30 |
|
63 | | - it "shows the most recent submission" do |
64 | | - get :edit |
| 31 | + it "assigns the most recent submission to submission_to_show" do |
| 32 | + get :edit |
65 | 33 |
|
66 | | - expect(assigns(:submission_to_show)).to eq latest_efile_submission |
| 34 | + expect(assigns(:submission_to_show)).to eq efile_submission_last |
| 35 | + end |
67 | 36 | end |
68 | | - end |
69 | | - end |
70 | | - end |
71 | 37 |
|
72 | | - context "NY" do |
73 | | - let(:ny_intake) { create :state_file_ny_intake } |
74 | | - before do |
75 | | - sign_in ny_intake |
76 | | - end |
77 | | - |
78 | | - context "happy path" do |
79 | | - let!(:efile_submission) { create(:efile_submission, :notified_of_rejection, :for_state, data_source: ny_intake) } |
80 | | - |
81 | | - it "shows the most recent submission" do |
82 | | - get :edit |
| 38 | + context "return status" do |
| 39 | + it "maps to accepted, rejected, or pending" do |
| 40 | + create(:efile_submission, :accepted, :for_state, data_source: intake) |
| 41 | + get :edit |
| 42 | + expect(assigns(:return_status)).to eq 'accepted' |
| 43 | + |
| 44 | + create(:efile_submission, :notified_of_rejection, :for_state, data_source: intake) |
| 45 | + get :edit |
| 46 | + expect(assigns(:return_status)).to eq 'rejected' |
| 47 | + |
| 48 | + create(:efile_submission, :waiting, :for_state, data_source: intake) |
| 49 | + get :edit |
| 50 | + expect(assigns(:return_status)).to eq 'rejected' |
| 51 | + |
| 52 | + EfileSubmissionStateMachine.states.excluding("accepted", "notified_of_rejection", "waiting").each do |status| |
| 53 | + create(:efile_submission, status, :for_state, data_source: intake) |
| 54 | + get :edit |
| 55 | + expect(assigns(:return_status)).to eq 'pending' |
| 56 | + end |
| 57 | + end |
| 58 | + end |
83 | 59 |
|
84 | | - expect(assigns(:submission_to_show)).to eq efile_submission |
| 60 | + context "efile error" do |
| 61 | + context "should expose error" do |
| 62 | + [:notified_of_rejection, :waiting].each do |status| |
| 63 | + let!(:efile_submission) { create(:efile_submission, :rejected, :with_errors, :for_state, data_source: intake) } |
| 64 | + let(:error) { efile_submission.efile_submission_transitions.where(to_state: 'rejected').last.efile_errors.last } |
| 65 | + before do |
| 66 | + efile_submission.transition_to!(status) |
| 67 | + end |
| 68 | + |
| 69 | + it "when #{status}, assigns the last efile error attached to the last rejected transition" do |
| 70 | + get :edit |
| 71 | + |
| 72 | + expect(error).to be_a(EfileError) |
| 73 | + expect(assigns(:error)).to eq error |
| 74 | + end |
| 75 | + end |
| 76 | + end |
| 77 | + |
| 78 | + context "other status" do |
| 79 | + [:new, :preparing, :bundling, :queued, :transmitted, :ready_for_ack, :failed, :rejected, :accepted].each do |status| |
| 80 | + it "when #{status}, assigns nil" do |
| 81 | + create(:efile_submission, status, :for_state, data_source: intake) |
| 82 | + |
| 83 | + get :edit |
| 84 | + |
| 85 | + expect(assigns(:error)).to be_nil |
| 86 | + end |
| 87 | + end |
| 88 | + |
| 89 | + [:investigating, :fraud_hold, :resubmitted, :cancelled].each do |status| |
| 90 | + it "when #{status}, assigns nil even if errors exist" do |
| 91 | + efile_submission = create(:efile_submission, :rejected, :with_errors, :for_state, data_source: intake) |
| 92 | + efile_submission.transition_to!(status) |
| 93 | + error = efile_submission.efile_submission_transitions.where(to_state: 'rejected').last.efile_errors.last |
| 94 | + expect(error).to be_a(EfileError) |
| 95 | + |
| 96 | + get :edit |
| 97 | + |
| 98 | + expect(assigns(:error)).to be_nil |
| 99 | + end |
| 100 | + end |
| 101 | + end |
| 102 | + end |
85 | 103 | end |
86 | 104 | end |
87 | 105 | end |
|
0 commit comments