Skip to content

armgit / maybe

Public Imported from GitHub
0

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.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