The personal finance app for everyone (by everyone)
Ruby
fix(accounts): skip digest on sidebar fragment cache (#2776)
pro3958785f9a19c5e3
diff --git a/app/views/accounts/_account_sidebar_tabs.html.erb b/app/views/accounts/_account_sidebar_tabs.html.erbindex 9b90870910..5469f0c8d0 100644--- a/app/views/accounts/_account_sidebar_tabs.html.erb+++ b/app/views/accounts/_account_sidebar_tabs.html.erb@@ -1,6 +1,14 @@<%# locals: (family:, active_tab:, mobile: false) %>-<% cache account_sidebar_tabs_cache_key(family: family, active_tab: active_tab, mobile: mobile), expires_in: 12.hours do %>+<%# skip_digest: this fragment renders DS::* view components, which Rails'+ ERB dependency tracker mis-parses as a bogus "Ds/D" template dependency+ and then logs "Couldn't find template for digesting: Ds/D" on every cache+ miss. The cache key is already manually versioned via+ account_sidebar_tabs_cache_key ("account_sidebar_tabs_v2",+ invalidate_on_data_updates: true), so we opt out of automatic template+ digesting. Bump that version suffix when changing this template or its+ sidebar dependencies. %>+<% cache account_sidebar_tabs_cache_key(family: family, active_tab: active_tab, mobile: mobile), expires_in: 12.hours, skip_digest: true do %><div id="account-sidebar-tabs"><% if family.missing_data_provider? %><div class="mb-3">diff --git a/test/controllers/accounts_controller_test.rb b/test/controllers/accounts_controller_test.rbindex 898fc76da5..dd1a5eb3e6 100644--- a/test/controllers/accounts_controller_test.rb+++ b/test/controllers/accounts_controller_test.rb@@ -459,6 +459,32 @@ class AccountsControllerTest < ActionDispatch::IntegrationTestassert_nil holding.account_provider_id, "Holding should be detached from provider after unlink"end++ # Regression for #2516: the account sidebar fragment cache renders DS::* view+ # components, which Rails' ERB dependency tracker mis-parses as a bogus "Ds/D"+ # template dependency. With automatic digesting enabled that logged+ # "Couldn't find template for digesting: Ds/D" on every cache miss. The+ # fragment is manually versioned and opts out of digesting via skip_digest.+ test "sidebar fragment cache does not log a bogus template digest error" do+ log = StringIO.new+ logger = ActiveSupport::Logger.new(log)++ original_perform_caching = ActionController::Base.perform_caching+ original_view_logger = ActionView::Base.logger+ original_rails_logger = Rails.logger++ ActionController::Base.perform_caching = true+ ActionView::Base.logger = logger+ Rails.logger = logger++ get accounts_path+ assert_response :success+ assert_no_match(/Couldn't find template for digesting/, log.string)+ ensure+ ActionController::Base.perform_caching = original_perform_caching+ ActionView::Base.logger = original_view_logger+ Rails.logger = original_rails_logger+ endendclass AccountsControllerSimplefinCtaTest < ActionDispatch::IntegrationTest