mirror of
https://github.com/we-promise/sure.git
synced 2026-04-07 14:31:25 +00:00
Keep disabled accounts visible for toggling (#361)
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user