From c701755b02a182eb3f8073fed8201bb92b499a7c Mon Sep 17 00:00:00 2001 From: Zach Gollwitzer Date: Sat, 24 May 2025 19:23:36 -0400 Subject: [PATCH] Require upstream item removal to delete plaid item --- app/models/plaid_item.rb | 3 --- test/controllers/users_controller_test.rb | 2 ++ test/models/plaid_item_test.rb | 8 -------- 3 files changed, 2 insertions(+), 11 deletions(-) diff --git a/app/models/plaid_item.rb b/app/models/plaid_item.rb index ce828288..be022a08 100644 --- a/app/models/plaid_item.rb +++ b/app/models/plaid_item.rb @@ -108,11 +108,8 @@ class PlaidItem < ApplicationRecord end private - # Silently swallow and report error so that we don't block the user from deleting the item def remove_plaid_item plaid_provider.remove_item(access_token) - rescue StandardError => e - Sentry.capture_exception(e) end # Plaid returns mutually exclusive arrays here. If the item has made a request for a product, diff --git a/test/controllers/users_controller_test.rb b/test/controllers/users_controller_test.rb index bd68fe77..3909c62d 100644 --- a/test/controllers/users_controller_test.rb +++ b/test/controllers/users_controller_test.rb @@ -40,6 +40,8 @@ class UsersControllerTest < ActionDispatch::IntegrationTest budget = budgets(:one) plaid_item = plaid_items(:one) + Provider::Plaid.any_instance.expects(:remove_item).with(plaid_item.access_token).once + perform_enqueued_jobs(only: FamilyResetJob) do delete reset_user_url(@user) end diff --git a/test/models/plaid_item_test.rb b/test/models/plaid_item_test.rb index c9c80059..b4f46bcd 100644 --- a/test/models/plaid_item_test.rb +++ b/test/models/plaid_item_test.rb @@ -16,12 +16,4 @@ class PlaidItemTest < ActiveSupport::TestCase @plaid_item.destroy end end - - test "if plaid item not found, silently continues with deletion" do - @plaid_provider.expects(:remove_item).with(@plaid_item.access_token).raises(Plaid::ApiError.new("Item not found")) - - assert_difference "PlaidItem.count", -1 do - @plaid_item.destroy - end - end end