The personal finance app for everyone
Do not raise on Plaid item not found exceptions for item deletions (#1646)
Zach Gollwitzer72fd17770734
diff --git a/app/models/plaid_item.rb b/app/models/plaid_item.rbindex 79087900..cbbe14bb 100644--- a/app/models/plaid_item.rb+++ b/app/models/plaid_item.rb@@ -131,5 +131,7 @@ class PlaidItem < ApplicationRecorddef remove_plaid_itemplaid_provider.remove_item(access_token)+ rescue StandardError => e+ Rails.logger.warn("Failed to remove Plaid item #{id}: #{e.message}")endenddiff --git a/test/models/plaid_item_test.rb b/test/models/plaid_item_test.rbindex d689e855..e18b1785 100644--- a/test/models/plaid_item_test.rb+++ b/test/models/plaid_item_test.rb@@ -18,4 +18,16 @@ class PlaidItemTest < ActiveSupport::TestCase@plaid_item.destroyendend++ test "if plaid item not found, silently continues with deletion" do+ @plaid_provider = mock++ PlaidItem.stubs(:plaid_provider).returns(@plaid_provider)++ @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