The personal finance app for everyone (by everyone)
Ruby
Stop the Plaid refresh check from loading dalli (#3846)
Guillem Arias Faustec181fe1c6485
diff --git a/app/models/plaid_item.rb b/app/models/plaid_item.rbindex 2e3a985e0d..388ee02930 100644--- a/app/models/plaid_item.rb+++ b/app/models/plaid_item.rb@@ -168,9 +168,10 @@ class PlaidItem < ApplicationRecordenddef shared_transactions_refresh_cache?+ # Compared by name: referencing MemCacheStore autoloads it, which raises+ # LoadError without the dalli gem, and SolidCache isn't a dependency.shared_cache = Rails.cache.is_a?(ActiveSupport::Cache::RedisCacheStore) ||- Rails.cache.is_a?(ActiveSupport::Cache::MemCacheStore) ||- Rails.cache.class.name == "SolidCache::Store"+ Rails.cache.class.name.in?(%w[ActiveSupport::Cache::MemCacheStore SolidCache::Store])Rails.logger.warn("Plaid transaction refresh requires a shared Rails cache store") unless shared_cacheshared_cachediff --git a/test/models/plaid_item_test.rb b/test/models/plaid_item_test.rbindex 0f57b26039..e18b678d80 100644--- a/test/models/plaid_item_test.rb+++ b/test/models/plaid_item_test.rb@@ -183,6 +183,14 @@ class PlaidItemTest < ActiveSupport::TestCaseendend+ # The test env's null store runs the real check. Naming MemCacheStore there+ # autoloads it, and that raises LoadError without the dalli gem.+ test "user sync skips provider refresh on an unshared cache without loading dalli" do+ assert_no_enqueued_jobs only: PlaidTransactionsRefreshJob do+ @plaid_item.request_transactions_refresh_later+ end+ end+test "user sync releases cooldown lease when refresh job is not enqueued" do@plaid_item.stubs(:shared_transactions_refresh_cache?).returns(true)Rails.cache.stubs(:write).returns(true)