mirror of
https://github.com/we-promise/sure.git
synced 2026-04-07 14:31:25 +00:00
* feat(config): add Lunchflow runtime configuration flags * feat(api): add include_pending parameter to Lunchflow API * feat(processor): add pending metadata support to Lunchflow processor * feat(processor): generate temporary IDs for pending transactions * feat(importer): integrate pending transaction support in sync * fix(importer): improve deduplication for transactions without IDs * feat(model): add Lunchflow pending support to Transaction scopes * test: add Lunchflow processor pending metadata tests * docs: update AGENTS.md for Lunchflow pending support * chore: remove unused variable * fix: simplify key check * fix: dotenv-linter key order * fix: avoid collapsing distinct pending transactions * fix: prevent unbounded raw payload growth for blank IDs
60 lines
2.2 KiB
Ruby
60 lines
2.2 KiB
Ruby
require "test_helper"
|
|
|
|
class TransactionTest < ActiveSupport::TestCase
|
|
test "pending? is true when extra.simplefin.pending is truthy" do
|
|
transaction = Transaction.new(extra: { "simplefin" => { "pending" => true } })
|
|
|
|
assert transaction.pending?
|
|
end
|
|
|
|
test "pending? is true when extra.plaid.pending is truthy" do
|
|
transaction = Transaction.new(extra: { "plaid" => { "pending" => "true" } })
|
|
|
|
assert transaction.pending?
|
|
end
|
|
|
|
test "pending? is true when extra.lunchflow.pending is truthy" do
|
|
transaction = Transaction.new(extra: { "lunchflow" => { "pending" => true } })
|
|
|
|
assert transaction.pending?
|
|
end
|
|
|
|
test "pending? is false when no provider pending metadata is present" do
|
|
transaction = Transaction.new(extra: { "plaid" => { "pending" => false } })
|
|
|
|
assert_not transaction.pending?
|
|
end
|
|
|
|
test "investment_contribution is a valid kind" do
|
|
transaction = Transaction.new(kind: "investment_contribution")
|
|
|
|
assert_equal "investment_contribution", transaction.kind
|
|
assert transaction.investment_contribution?
|
|
end
|
|
|
|
test "all transaction kinds are valid" do
|
|
valid_kinds = %w[standard funds_movement cc_payment loan_payment one_time investment_contribution]
|
|
|
|
valid_kinds.each do |kind|
|
|
transaction = Transaction.new(kind: kind)
|
|
assert_equal kind, transaction.kind, "#{kind} should be a valid transaction kind"
|
|
end
|
|
end
|
|
|
|
test "ACTIVITY_LABELS contains all valid labels" do
|
|
assert_includes Transaction::ACTIVITY_LABELS, "Buy"
|
|
assert_includes Transaction::ACTIVITY_LABELS, "Sell"
|
|
assert_includes Transaction::ACTIVITY_LABELS, "Sweep In"
|
|
assert_includes Transaction::ACTIVITY_LABELS, "Sweep Out"
|
|
assert_includes Transaction::ACTIVITY_LABELS, "Dividend"
|
|
assert_includes Transaction::ACTIVITY_LABELS, "Reinvestment"
|
|
assert_includes Transaction::ACTIVITY_LABELS, "Interest"
|
|
assert_includes Transaction::ACTIVITY_LABELS, "Fee"
|
|
assert_includes Transaction::ACTIVITY_LABELS, "Transfer"
|
|
assert_includes Transaction::ACTIVITY_LABELS, "Contribution"
|
|
assert_includes Transaction::ACTIVITY_LABELS, "Withdrawal"
|
|
assert_includes Transaction::ACTIVITY_LABELS, "Exchange"
|
|
assert_includes Transaction::ACTIVITY_LABELS, "Other"
|
|
end
|
|
end
|