mirror of
https://github.com/maybe-finance/maybe.git
synced 2025-07-31 02:59:39 +02:00
First sketch of budgeting module
This commit is contained in:
parent
5d1a2937bb
commit
9a2a7b31d4
45 changed files with 342 additions and 84 deletions
28
test/models/transfer_matcher_test.rb
Normal file
28
test/models/transfer_matcher_test.rb
Normal file
|
@ -0,0 +1,28 @@
|
|||
require "test_helper"
|
||||
|
||||
class TransferMatcherTest < ActiveSupport::TestCase
|
||||
include Account::EntriesTestHelper
|
||||
|
||||
setup do
|
||||
@family = families(:dylan_family)
|
||||
@matcher = TransferMatcher.new(@family)
|
||||
end
|
||||
|
||||
test "matches entries with opposite amounts and different accounts within 4 days" do
|
||||
entry1 = create_transaction(account: accounts(:depository), amount: 100, date: Date.current)
|
||||
entry2 = create_transaction(account: accounts(:credit_card), amount: -100, date: 2.days.ago.to_date)
|
||||
|
||||
assert_difference "Account::Transfer.count", 1 do
|
||||
@matcher.match!([ entry1, entry2 ])
|
||||
end
|
||||
end
|
||||
|
||||
test "doesn't match entries more than 4 days apart" do
|
||||
entry1 = create_transaction(account: accounts(:depository), amount: 100, date: Date.current)
|
||||
entry2 = create_transaction(account: accounts(:credit_card), amount: -100, date: Date.current + 5.days)
|
||||
|
||||
assert_no_difference "Account::Transfer.count" do
|
||||
@matcher.match!([ entry1, entry2 ])
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue