Keep disabled accounts visible for toggling (#361)

This commit is contained in:
Juan José Mata
2025-11-21 20:02:25 +01:00
committed by GitHub
parent 25ac345f0b
commit 51d1cea51d
3 changed files with 28 additions and 2 deletions

View File

@@ -4,7 +4,7 @@ class AccountsController < ApplicationController
def index
@manual_accounts = family.accounts
.visible_manual
.listable_manual
.order(:name)
@plaid_items = family.plaid_items.ordered
@simplefin_items = family.simplefin_items.ordered.includes(:syncs)
@@ -18,7 +18,7 @@ class AccountsController < ApplicationController
latest_sync = item.syncs.ordered.first
@simplefin_sync_stats_map[item.id] = (latest_sync&.sync_stats || {})
@simplefin_has_unlinked_map[item.id] = item.family.accounts
.visible_manual
.listable_manual
.exists?
end

View File

@@ -32,6 +32,10 @@ class Account < ApplicationRecord
visible.manual
}
scope :listable_manual, -> {
manual.where.not(status: :pending_deletion)
}
has_one_attached :logo
delegated_type :accountable, types: Accountable::TYPES, dependent: :destroy

View File

@@ -130,6 +130,28 @@ class AccountsControllerTest < ActionDispatch::IntegrationTest
assert_equal "Depository account scheduled for deletion", flash[:notice]
end
test "disabling an account keeps it visible on index" do
@account.disable!
get accounts_path
assert_response :success
assert_includes @response.body, @account.name
assert_includes @response.body, "account_#{@account.id}_active"
end
test "toggle_active disables and re-enables an account" do
patch toggle_active_account_url(@account)
assert_redirected_to accounts_path
@account.reload
assert @account.disabled?
patch toggle_active_account_url(@account)
assert_redirected_to accounts_path
@account.reload
assert @account.active?
end
test "select_provider shows available providers" do
get select_provider_account_url(@account)
assert_response :success