Skip to content

Commit

Permalink
Ensure joint_account_holder_name is set to nil if payment method changes
Browse files Browse the repository at this point in the history
  • Loading branch information
arinchoi03 committed Nov 21, 2024
1 parent 9ce7a6e commit 32d75ff
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 9 deletions.
3 changes: 1 addition & 2 deletions app/models/state_file_md_intake.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
# account_number :string
# account_type :integer default("unfilled"), not null
# bank_authorization_confirmed :integer default("unfilled"), not null
# bank_name :string
# city :string
# confirmed_permanent_address :integer default("unfilled"), not null
# consented_to_terms_and_conditions :integer default("unfilled"), not null
Expand Down Expand Up @@ -136,12 +135,12 @@ def calculate_age(dob, inclusive_of_jan_1)
def sanitize_bank_details
if (payment_or_deposit_type || "").to_sym != :direct_deposit
self.account_type = "unfilled"
self.bank_name = nil
self.routing_number = nil
self.account_number = nil
self.withdraw_amount = nil
self.date_electronic_withdrawal = nil
self.account_holder_name = nil
self.joint_account_holder_name = nil
end
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
get :edit
expect(response).to be_successful
expect(response_html).to have_text "Good news"
expect(response_html).to have_text "Bank name"
expect(response_html).to have_text "Account Holder Name"
end
end
end
1 change: 0 additions & 1 deletion spec/factories/state_file_md_intakes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
# account_number :string
# account_type :integer default("unfilled"), not null
# bank_authorization_confirmed :integer default("unfilled"), not null
# bank_name :string
# city :string
# confirmed_permanent_address :integer default("unfilled"), not null
# consented_to_terms_and_conditions :integer default("unfilled"), not null
Expand Down
4 changes: 3 additions & 1 deletion spec/forms/state_file/md_tax_refund_form_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@
routing_number: "019456124",
account_number: "12345",
account_type: "checking",
account_holder_name: "Laney Knope"
account_holder_name: "Laney Knope",
joint_account_holder_name: "Lacey Knope"
)
end

Expand All @@ -73,6 +74,7 @@
expect(intake.account_number).to be_nil
expect(intake.routing_number).to be_nil
expect(intake.account_holder_name).to be_nil
expect(intake.joint_account_holder_name).to be_nil
end
end
end
Expand Down
7 changes: 3 additions & 4 deletions spec/models/state_file_md_intake_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
# account_number :string
# account_type :integer default("unfilled"), not null
# bank_authorization_confirmed :integer default("unfilled"), not null
# bank_name :string
# city :string
# confirmed_permanent_address :integer default("unfilled"), not null
# consented_to_terms_and_conditions :integer default("unfilled"), not null
Expand Down Expand Up @@ -128,23 +127,23 @@
create :state_file_md_intake,
payment_or_deposit_type: "direct_deposit",
account_type: "checking",
bank_name: "Wells Fargo",
routing_number: "123456789",
account_number: "123",
withdraw_amount: 123,
date_electronic_withdrawal: Date.parse("April 1, 2023"),
account_holder_name: "Neil Peart"
account_holder_name: "Neil Peart",
joint_account_holder_name: "Beatrice Peart"
end

it "clears other account fields" do
expect {
intake.update(payment_or_deposit_type: "mail")
}.to change(intake.reload, :account_type).to("unfilled")
.and change(intake.reload, :bank_name).to(nil)
.and change(intake.reload, :routing_number).to(nil).and change(intake.reload, :account_number).to(nil)
.and change(intake.reload, :withdraw_amount).to(nil)
.and change(intake.reload, :date_electronic_withdrawal).to(nil)
.and change(intake.reload, :account_holder_name).to(nil)
.and change(intake.reload, :joint_account_holder_name).to(nil)
end
end
end
Expand Down

0 comments on commit 32d75ff

Please sign in to comment.