The personal finance app for everyone
Require upstream item removal to delete plaid item
Zach Gollwitzerc701755b02a1
diff --git a/app/models/plaid_item.rb b/app/models/plaid_item.rbindex ce828288..be022a08 100644--- a/app/models/plaid_item.rb+++ b/app/models/plaid_item.rb@@ -108,11 +108,8 @@ class PlaidItem < ApplicationRecordendprivate- # Silently swallow and report error so that we don't block the user from deleting the itemdef remove_plaid_itemplaid_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.rbindex bd68fe77..3909c62d 100644--- a/test/controllers/users_controller_test.rb+++ b/test/controllers/users_controller_test.rb@@ -40,6 +40,8 @@ class UsersControllerTest < ActionDispatch::IntegrationTestbudget = 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) dodelete reset_user_url(@user)enddiff --git a/test/models/plaid_item_test.rb b/test/models/plaid_item_test.rbindex 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.destroyendend-- 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- endend